Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

left_join() error message names wrong variable in y #6465

Closed
cjyetman opened this issue Sep 17, 2022 · 1 comment · Fixed by #6467
Closed

left_join() error message names wrong variable in y #6465

cjyetman opened this issue Sep 17, 2022 · 1 comment · Fixed by #6467
Assignees
Labels
bug an unexpected problem or unintended behavior tables 🧮 joins and set operations

Comments

@cjyetman
Copy link
Contributor

When joining two tables by differently named columns, if they are incompatible types the error message uses the name of the by column in table x as the name of the by column in table y, e.g. y$var1 which does not exist in the example below.

library(dplyr)

tb1 <-
  tibble(
    var1 = 1,
    value = 2
  )

tb2 <-
  tibble(
    id1 = "1",
    value = 2
  )

left_join(tb1, tb2, by = c(var1 = "id1"))
#> Error in `left_join()`:
#> ! Can't join on `x$var1` x `y$var1` because of incompatible types.
#> ℹ `x$var1` is of type <double>>.
#> ℹ `y$var1` is of type <character>>.

using:
R version 4.2.1
dplyr 1.0.10
rlang 1.0.5
cli 3.4.0

@hadley hadley added bug an unexpected problem or unintended behavior tables 🧮 joins and set operations labels Sep 19, 2022
@hadley
Copy link
Member

hadley commented Sep 19, 2022

Still see the same failure with dev dplyr:

library(dplyr, warn.conflicts = FALSE)

df1 <- tibble(var1 = 1, val = 2)
df2 <- tibble(var2 = "1", val = 2)

left_join(df1, df2, by = join_by(var1 == var2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior tables 🧮 joins and set operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants