You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
library(dplyr, warn.conflicts=FALSE)
#> Warning: package 'dplyr' was built under R version 4.2.3x<- tibble(a=1, b=1, aa=1) |>
select(all_of(starts_with("a")))
y<- tibble(b=1, a=1, aa=1) |>
select(all_of(starts_with("a")))
list(x, y)
#> [[1]]#> # A tibble: 1 × 2#> a aa#> <dbl> <dbl>#> 1 1 1#> #> [[2]]#> # A tibble: 1 × 2#> a aa#> <dbl> <dbl>#> 1 1 1severalEvals<-function(name) {
x<- tibble(a=1, b=1, aa=1) |>
select(all_of(name))
y<- tibble(b=1, a=1, aa=1) |>
select(all_of(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#> b aa#> <dbl> <dbl>#> 1 1 1
This is expected, tidyselection require {{ for passing arguments.
They sort of work in some cases with lazy evaluation (as in your several-eval example). However once the argument is forced it will not be evaluated again in that case.
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: