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

tidyselect Warning when using pivot_wider with a variable for column name #1581

Closed
martinmodrak opened this issue Nov 1, 2024 · 1 comment

Comments

@martinmodrak
Copy link

Some of the code in tidyr seems to not have been updated to reflect tidyselect 1.1.0 requirement to use all_of / any_of. This results in unnecessary warnings, but for some reason only when column names are passed as variables.

df <- data.frame(id = 1:40, a = rep(LETTERS[1:2], each = 20), val = rnorm(40))
#No warning
pivot_wider(df, names_from = "a", values_from = "val")

varname <- "val"
# Warning
pivot_wider(df, names_from = "a", values_from = varname)

The warning produced is

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(varname)

  # Now:
  data %>% select(all_of(varname))

See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.

Note: reprex requires a fresh session as the warning is not repeated on subsequent runs

@martinmodrak
Copy link
Author

martinmodrak commented Nov 1, 2024

Oh, that's my bad, I probably should've just use all_of myself, right?

@martinmodrak martinmodrak closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
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

No branches or pull requests

1 participant