【发布时间】:2020-04-22 17:05:24
【问题描述】:
我正在尝试将str_detect 和& 用于filter 数据帧的简写:
library(tidyverse)
df <- data.frame(type = c("age", "age and sex", "sex"))
# type
# 1 age
# 2 age and sex
# 3 sex
我想缩短这个管道
df %>%
filter(str_detect(type, "age") & str_detect(type, "sex"))
# type
# 1 age and sex
所以我想通过pattern <- c("age", "sex") 将过滤器通过管道传输到map,并且可能以某种方式使用reduce?
谢谢
【问题讨论】: