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

FR: add case sensibility option for any_of() and all_of() #344

Open
DanChaltiel opened this issue May 16, 2023 · 2 comments
Open

FR: add case sensibility option for any_of() and all_of() #344

DanChaltiel opened this issue May 16, 2023 · 2 comments

Comments

@DanChaltiel
Copy link

DanChaltiel commented May 16, 2023

Hi,

Would it be possible to add a ignore.case=TRUE option in any_of() and all_of() like there is in starts_with() and its friends?

Workaround in the meantime:

any_of2 = function(x, ignore.case=TRUE, ...){
  matches(paste(paste0("^",x,"$"), collapse="|"), ignore.case=ignore.case, ...)
}
dplyr::select(iris, any_of2(c("sepal.length", "sepal.width"))) %>% names()
#> [1] "Sepal.Length" "Sepal.Width"
@lionel-
Copy link
Member

lionel- commented May 16, 2023

hmm I'm not sure this matches the spirit of these helpers because they are meant to be used in programmatic contexts where you need to be sure of the names of the columns you are targeting.

@DanChaltiel
Copy link
Author

Well in my personal case, I'm confronted with a set of data frames from which I should select 2 columns that can or cannot exist, and when they exist they can be uppercase or lowercase.
This is because they can come from either R (lowercase) or SAS (uppercase).
Maybe this is a very specific case but I think many can relate, especially when datasets share a common structure but are implemented in different systems.

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

2 participants