Skip to content

tidyselect deprecate warnings #178

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

Closed
dajmcdon opened this issue May 7, 2023 · 0 comments · Fixed by #180
Closed

tidyselect deprecate warnings #178

dajmcdon opened this issue May 7, 2023 · 0 comments · Fixed by #180

Comments

@dajmcdon
Copy link
Contributor

dajmcdon commented May 7, 2023

This warning happens intermittently:

#> Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
#> ℹ Please use `all_of()` or `any_of()` instead.
#>   # Was:
#>   data %>% select(old)
#> 
#>   # Now:
#>   data %>% select(all_of(old))

I've had difficulty determining it's origin, but it seems to be due to the pattern dplyr::rename(df, !!new := old) when new and old are chr function arguments. This should instead be dplyr::rename(df, !!new := {{ old }}) to silence the warning.

fun <- function(df, new, old) {
  dplyr::rename(df, !!new := old)
}


fun1 <- function(df, new, old) {
  dplyr::rename(df, !!new := {{ old }})
}

options(lifecycle_verbosity = "warning") # forces the warning to happen everytime
tib <- tibble::tibble(x = 1:5, y = 1:5)
fun(tib, "z", "y")
#> Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
#> ℹ Please use `all_of()` or `any_of()` instead.
#>   # Was:
#>   data %>% select(old)
#> 
#>   # Now:
#>   data %>% select(all_of(old))
#> 
#> See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> # A tibble: 5 × 2
#>       x     z
#>   <int> <int>
#> 1     1     1
#> 2     2     2
#> 3     3     3
#> 4     4     4
#> 5     5     5
fun1(tib, "z", "y")
#> # A tibble: 5 × 2
#>       x     z
#>   <int> <int>
#> 1     1     1
#> 2     2     2
#> 3     3     3
#> 4     4     4
#> 5     5     5

Created on 2023-05-07 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant