Possible Duplicate:
Standard way to remove multiple elements from a dataframe
我知道在R中,如果你在搜索另一个组的子集或基于id的匹配,你会使用
subset(df1, df1$id %in% idNums1)
我的问题是如何做相反的事情,或者 Select 与ID向量不匹配的项.
我try 使用!
,但收到了错误消息
subset(df1, df1$id !%in% idNums1)
我想我的后援就是这样做:
matches <- subset(df1, df1$id %in% idNums1)
nonMatches <- df1[(-matches[,1]),]
但我希望有更有效的方法.