In dplyr, how to select columns contains cat
or b
? select(matches("('cat')('b')"))
seems can't work
library(tidyverse)
ori_df <- data.frame(ccat_a=1,wt=2,cat_b=1,cf=6,fbw=4)
ori_df %>% select(matches("('cat')('b')"))
Use contains
from tidyselect
ori_df <- data.frame(ccat_a=1,wt=2,cat_b=1,cf=6,fbw=4)
ori_df %>%
select(contains(c("cat", "b")))