-
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
Should num_range select helper work together with e.g. ends_with or get an additional argument "suffix = "? #229
Comments
Thanks for the suggestion. In this case I'd rather not add features to |
Understood, but in this case there's still the remaining bug (IMO) that the combination of
So I'd hope for a respective re-opening of the issue. Not sure though if that is a tidyselect problem or a dplyr/select problem. |
ok reopening so I can take a look at your reprex when I get back to work on tidyselect. |
library(dplyr, warn.conflicts = FALSE)
df <- tibble(
x1 = c(1, 2),
x2 = c(3, 4),
x3 = c(5, 6),
x4y = c(7, 8),
x1_rec = c(9, 10),
x2_rec = c(11, 12),
x4y_rec = c(13, 14)
)
df %>% select(num_range("x", 1:2)) |> names()
#> [1] "x1" "x2"
df %>% select(ends_with("_rec")) |> names()
#> [1] "x1_rec" "x2_rec" "x4y_rec" Created on 2022-08-12 by the reprex package (v2.0.1) It's because |
(note - copy from: tidyverse/dplyr#5764)
I was just puzzled when I tried to select certain columns of my data frame that a) start with a letter, followed by a number (for which the
num_range
helper would be ideal) and b) also end with a certain string, e.g. "_rec" (for whichends_with
would be perfect).However, using this approach, a data frame with 0 columns is returned. I guess that num_range is only suited for full matches, however the help function doesn't say a word about it and I also think num_range would benefit from an option to not only add a prefix, but also a suffix.
What I could imagine is really just an extension of the num_range function, e.g.:
The text was updated successfully, but these errors were encountered: