test <- data.frame(A = c(1,2,3,1,0), B = c(1,1,5,6,2))
我想删除A = 1和B = 1
的观察例如:
test <- test[-which(test$A == 1 & test$B == 1),]
如何在dplyr中完成?
test <- filter(test, -(test$A == 1 & test$B == 1))
Error in eval(substitute(expr), envir, enclos) :
filter condition does not evaluate to a logical vector.
答案 0 :(得分:0)
filter(test, !(A == 1 & B == 1))
或
filter(test, (A != 1 | B != 1))
或
slice(test, -which(test$A == 1 & test$B == 1))