本文介绍了dplyr排除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找

SELECT user_id, item
  FROM users
  WHERE user_id NOT IN (1, 5, 6, 7, 11, 17, 18); -- admin accounts

我可以使用
users%> %filter(user_id!= 1),但无法想象完全使用多个&&

I can useusers %>% filter(user_id != 1) but can't imagine using multiple && all the way.

是否可以排除许多行?

Is there a way to exclude a number of rows?

推荐答案

您可以使用% in%

filtered_users <- filter(users, !user_id %in% c(1, 5, 6, 7, 11, 17, 18))

这是基于。我只是用谷歌搜索 dplyr not in,这是第一个结果。 Google是您学习新事物的朋友。另外,正如@thelatemail所说,是基本的R函数。

This is based on https://stackoverflow.com/a/34444336/1152809. I just googled "dplyr not in" and this was the first result. Google is your friend when learning new things. Also, as @thelatemail said, %in% is a base R function.

这篇关于dplyr排除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 00:05