【发布时间】:2015-06-22 15:18:27
【问题描述】:
我想从我的 data.frame 中删除其唯一值组合在数据框中重复 >= 4 次的行。在此示例中,我只需要第 1、2、6 和 7 行,因为值 IR、IR_OSR、2 和 hello 在此示例中重复了 4 次。
> DB[1:5,c("MegaSite","General.location","ID","call.type")]
MegaSite General.location ID call.type
1 IR IR_OSR 2 hello
2 IR IR_OSR 2 hello
3 IR IR_OSR M x
4 IR IR_OSR M x
5 IR IR_OSR M z
6 IR IR_OSR 2 hello
7 IR IR_OSR 2 hello
> dim(DB)
[1] 25434 76
我已经尝试了另一个最近的问题 (Finding value pairs that occur more than once in a data.table in R) 中建议的以下代码,
>DB[,.N>3 , list("MegaSite","General.location","ID","call.type")]
但是我得到了这个错误
Error in drop && !has.j : invalid 'x' type in 'x && y'
这是一个更大的示例数据集的链接,该数据集仅包含我的实际数据集中的相关列: DB_IRsample.txt
【问题讨论】: