-
Notifications
You must be signed in to change notification settings - Fork 39
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
Incorrect evaluation of tidyselect expressions inside functions? #348
Comments
@MimiYuchenGuo have find that we could solve it with library(dplyr, warn.conflicts = FALSE)
#> Warning: package 'dplyr' was built under R version 4.2.3
severalEvals <- function(name) {
x <- tibble(a = 1, b = 1, aa = 1) |>
select({{name}})
y <- tibble(b = 1, a = 1, aa = 1) |>
select({{name}})
list(x, y)
}
severalEvals(starts_with("a"))
#> [[1]]
#> # A tibble: 1 × 2
#> a aa
#> <dbl> <dbl>
#> 1 1 1
#>
#> [[2]]
#> # A tibble: 1 × 2
#> a aa
#> <dbl> <dbl>
#> 1 1 1 Created on 2024-03-07 with reprex v2.0.2 But it is still an unexpected behavior for me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So for me the following behavior is not expected... Any thought?
For what I've seen the name value inside the function changes its value to the position of the selected columns in the first evaluation. So the second evaluation does not evaluate the expression, instead it selects the same position columns than the first evaluation.
In fact, if you add
print(name)
inside the function severalEvals, instead of returning the typical warning tidyselect expressions can not be evaluated... It returns name = c(1, 3).Created on 2024-03-07 with reprex v2.0.2
Is this the expected behavior? Is there a way to get the behavior I was expecting?
The text was updated successfully, but these errors were encountered: