r - filter()中的OR运算符?

标签 r filter operators dplyr

我想使用filter()函数查找x值小于或等于4或y值大于5的类型。我认为这可能是一个简单的解决方法,我只是在?filter()上找不到很多信息。我想差不多了:

x = c(1, 2, 3, 4, 5, 6)
y = c(3, 6, 1, 9, 1, 1)
type = c("cars", "bikes", "trains")

df = data.frame(x, y, type)

df2 = df %>% 
      filter(x<=4)

最佳答案

尝试

df %>%
    filter(x <=4| y>=5)

关于r - filter()中的OR运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36134694/

相关文章:

jquery - 根据 div 的 id 过滤

Powershell 从一个列表中过滤出另一个列表

java == 运算符

python - 这些运算符是什么意思(**、^、%、//)?

Matlab,运算符 A\B

python - R Markdown 代码折叠不适用于 bash,Python 代码块

r - ggplot geom_linerange 中的 Alpha 由 Mac 上的观察次数决定

r - Git 推送失败 (Github/RStudio)

javascript - R 传单 : Assign multiple groups to a layer to filter data and change column represented

java - 如何过滤字符串/列表?