根据另一列中的值在一个列中重复复制的行删除行
提出了一个类似的问题在这里。但是,我没有设法对我的特定问题采用该解决方案,因此是一个单独的问题。
一个示例数据集:
id group
1 1 5
2 1 998
3 2 2
4 2 3
5 3 998
我想删除在ID中重复的所有行且组具有值998的行。 在此示例中,仅应删除第2行。
我尝试了一些事情:
df1 <- df %>%
subset((unique(by = "id") | group != 998))
但是
ins.factor(x)中的错误(X):参数“ x”,没有默认值
默认
A similar question was asked here. However, I did not manage to adopt that solution to my particular problem, hence the separate question.
An example dataset:
id group
1 1 5
2 1 998
3 2 2
4 2 3
5 3 998
I would like to delete all rows that are duplicated in id and where group has value 998.
In this example, only row 2 should be deleted.
I tried something along those lines:
df1 <- df %>%
subset((unique(by = "id") | group != 998))
but got
Error in is.factor(x) : Argument "x" is missing, with no default
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个想法,
如果您只想从组中删除998条目,
Here is an idea
In case you want to remove only the 998 entry from the group then,
一种方法可能是:
One way could be: