I want to select cols using colnames and their values ββin one channel chain without reference to other objects, for example NAMES <- names(d) . Can I do this with select_if() ?
For instance,
I can use colnames to select cols.
( select(matches(...)) smarter than only calling).
library(dplyr) d <- iris %>% select(-Species) %>% tibble::as.tibble() d %>% select_if(stringr::str_detect(names(.), "Petal"))
And I can use the values.
d %>% select_if(~ mean(.) > 5)
But how to use both of them? (especially OR)
Below code is what I want (of course not to run).
d %>% select_if(stringr::str_detect(names(.), "Petal") | ~ mean(.) > 5)
Any help would be greatly appreciated.
source share