-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Internal: slightly inaccurate as_join_by()
implementation for character
#7001
Comments
We do allow this though: unclass(dplyr::join_by("a" == "a"))
#> $exprs
#> $exprs[[1]]
#> "a" == "a"
#>
#>
#> $condition
#> [1] "=="
#>
#> $filter
#> [1] "none"
#>
#> $x
#> [1] "a"
#>
#> $y
#> [1] "a" But maybe that should be the "special" case, and coming from character should try to generate the "typical" case of |
What are the semantics of |
Out of curiosity, will suppressPackageStartupMessages(library(dplyr))
x <- data.frame(a = 1:5, b = 2:6)
y <- data.frame(a = 1:3, b = c(2, 3, 5), x = 2:4)
cols_by <- c("a", "b")
inner_join(x, y, by = cols_by)
#> a b x
#> 1 1 2 2
#> 2 2 3 3
# oops
inner_join(x, y, by = join_by(!!cols_by))
#> Error in `join_by()`:
#> ! Each element of `...` must be a single column name or a join by
#> expression.
#> ✖ Element 1 is not a name and not an expression.
inner_join(x, y, by = dplyr:::as_join_by(cols_by))
#> a b x
#> 1 1 2 2
#> 2 2 3 3 Created on 2024-03-20 with reprex v2.1.0 |
Do you need |
Ah, thanks! suppressPackageStartupMessages(library(dplyr))
x <- data.frame(a = 1:5, b = 2:6)
y <- data.frame(a = 1:3, b = c(2, 3, 5), x = 2:4)
cols_by <- c("a", "b")
inner_join(x, y, by = join_by(!!!cols_by))
#> a b x
#> 1 1 2 2
#> 2 2 3 3 Created on 2024-03-20 with reprex v2.1.0 But I do think we do not recommend using |
The old method is not going away, so if you have this case then I'd recommend just supplying the character vector as you did before But using
|
They are identical yes |
Should we support the invariant that two joins are identical iff their identical(dplyr::join_by("a" == "a"), dplyr::join_by(a == a)) because it will simplify code that analyzes |
Created on 2024-03-08 with reprex v2.1.0
I can work around, but I wonder if this may cause some downstream gotchas.
The text was updated successfully, but these errors were encountered: