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

Unexpected warnings about the usage of external vectors in selections #353

Closed
ramiromagno opened this issue Jul 17, 2024 · 2 comments
Closed

Comments

@ramiromagno
Copy link

ramiromagno commented Jul 17, 2024

Hi,

I thought I had changed all tidyselections to use all_of() / any_of() but I am now getting warnings in rhub's VMs. These warnings do not happen locally on my machine.

Example: https://github.com/pharmaverse/sdtm.oak/actions/runs/9976393726/job/27568469297#step:6:210.

If I look at the backtrace it seems that the warnings come from: dplyr::mutate(dat, !!!lst, .by = NULL, .keep = .keep, .after = .after) .

Any pointers on how I can replicate this locally? The fact that I don't see this happening locally has anything to do with direct / indirect usage, as discussed here: https://www.tidyverse.org/blog/2022/10/tidyselect-1-2-0/?

Original issue: pharmaverse/sdtm.oak#68.

Any help is appreciated!

@ramiromagno
Copy link
Author

Edit: I can replicate this locally now.

So I get these warnings:

Warning (test-mutate_cnd_df.R:72:3): mutate.cnd_df handles .after parameter correctly
Using an external vector in selections was deprecated in tidyselect 1.1.0.
i Please use `all_of()` or `any_of()` instead.
  # Was:
  data %>% select(.after)

  # Now:
  data %>% select(all_of(.after))

See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
Backtrace:
     ▆
  1. ├─dplyr::mutate(cnd_df, z = x + y, .after = "x") at test-mutate_cnd_df.R:72:3
  2. └─sdtm.oak:::mutate.cnd_df(cnd_df, z = x + y, .after = "x")
  3.   ├─dplyr::mutate(dat, !!!lst, .by = NULL, .keep = .keep, .after = .after) at sdtm.oak/R/cnd_df.R:443:3
  4.   └─dplyr:::mutate.data.frame(...)
  5.     └─dplyr:::mutate_relocate(...)
  6.       ├─dplyr::relocate(out, all_of(names), .before = !!before, .after = !!after)
  7.       └─dplyr:::relocate.data.frame(...)
  8.         └─dplyr:::eval_relocate(...)
  9.           └─tidyselect::eval_select(after, data, env = env, error_call = error_call)
 10.             └─tidyselect:::eval_select_impl(...)
 11.               ├─tidyselect:::with_subscript_errors(...)
 12.               │ └─base::withCallingHandlers(...)
 13.               └─tidyselect:::vars_select_eval(...)
 14.                 └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 15.                   └─tidyselect:::eval_sym(expr, data_mask, context_mask)

If I run the tests on the file containing this test with testthat::test_file("tests/testthat/test-mutate_cnd_df.R") all tests pass. If I run testthat::test_local() or devtools::test() these warnings come back to haunt me. What am I missing?

@ramiromagno
Copy link
Author

I missed completely that this issue was about the .after argument... even though it's in the error msg... (face palm)

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