我如何使用& |比较过滤器中的字符串?
AP = df1 %>%
filter( x == "AP" | "AC") %>%
group_by(y) %>%
summarise(Z = sum(Z))
答案 0 :(得分:0)
我在这里为您提供iris
数据的示例:
library(dplyr)
data(iris)
AP = iris %>%
filter( Species == "setosa" | Species =="virginica")
请记住重复变量名称:)
答案 1 :(得分:0)
您还可以使用|
:
%in%
语句
AP = df1 %>%
filter(x %in% c("AP","AC")) %>%
group_by(y) %>%
summarise(Z = sum(Z))