Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何从向量中删除多个值?
是否有任何内置函数允许我们删除向量中的特定元素组?
例子:
x<-c(2, 4, 6, 9, 10)
c(4,9,10)从中删除向量x
c(4,9,10)
x
您可以通过多种方式做到这一点,这是一种:
x[!x %in% c(4, 9, 10)]
或者你可以使用?is.element
?is.element
x[!is.element(x, c(4,9,10))]
这可能很有用
x<-c(2, 4, 6, 9, 10) y <- c(4,9,10) setdiff(x, y) 2 6