本文介绍了查找两个向量之间不重叠的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试识别未包含在其他向量中的元素.例如在两个向量中我有
I'm trying to identify elements which are not included in the other vector. For instance in two vectors I have
list.a <- c("James", "Mary", "Jack", "Sonia", "Michelle", "Vincent")
list.b <- c("James", "Sonia", "Vincent")
有没有办法验证哪些人没有重叠?在示例中,我想要获得包含 Mary、Jack 和 Michelle 的向量结果.
is there a way to verify which people do not overlap? In the example, I would want to get the vector result that contains Mary, Jack, and Michelle.
任何建议都会有所帮助!
Any suggestions will help!
推荐答案
是的,有办法:
setdiff(list.a, list.b)
# [1] "Mary" "Jack" "Michelle"
这篇关于查找两个向量之间不重叠的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!