Skip to content

For *_join functions, requesting handling when argument "on" is specified in place of "by" #6228

Closed
@baogorek

Description

@baogorek

As a heavy SQL user, I'm constantly using argument "on" instead of "by" in inner_join and left_join. These functions do echo what they're actually joining on, but it's easy to miss. I feel like these functions should stop you in your tracks if you try to use "on" or throw a warning and make the substitution.

Bit of a contrived example below, but in both cases it's clear the user is intending to join on "id" and not c("id", "x")

library(dplyr)
df <- data.frame(id = c(1,2), x = c(3.4, 2.6))
df2 <- data.frame(id = c(1,2), x = c(3.4, 2.7), z = c(4.4, 5.4))

df %>% inner_join(df2, on="id")
df %>% inner_join(df2, by="id")

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementtables 🧮joins and set operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions