Here is some sample data
library(tidyverse)
data <- matrix(runif(20), ncol = 4)
colnames(data) <- c("mt100", "cp001", "cp002", "cp003")
data <- as_tibble(data)
The real data set has many more columns but it stands that there are many columns that all start with "cp". In dplyr
I can select all these columns
data %>%
select(starts_with("cp"))
Is there a way in which I can use the starts_with
(or similar function) to filter by multiple columns without having to explicitly write them all? I'm thinking something like this
data %>%
filter(starts_with("cp") > 0.2)