如何获取未在R中的向量中指定的数据帧的所有行?

时间:2013-09-27 20:11:38

标签: r

我正在寻找一种优雅的,类似于R的方法来捕获数据框中没有将其索引列在向量中的行:

table.combos <- matrix(data = 1:12, nrow = 10, ncol = 6, byrow=T)
table.combos
not.these<-c(2,4,5,9)
x<-table.combos[c(not.these),]
#y<- everything not in x

1 个答案:

答案 0 :(得分:2)

只需使用与以下相同的索引向量:

y <- table.combos[-not.these,]

告诉您选择table.combos中的所有行,但选择not.these向量中的所有行。