如何检测向量是特定向量的子集? [英] How to detect that a vector is subset of specific vector?
本文介绍了如何检测向量是特定向量的子集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个这样的向量(集合):
I have two vectors (sets) like this:
first<-c(1,2,3,4,5)
second<-c(2,4,5)
如何检测second
是否是first
的子集?有这个功能吗?
how can I detect that whether second
is subset of first
or not? is there any function for this?
推荐答案
这是一种方法
> all(second %in% first)
[1] TRUE
这篇关于如何检测向量是特定向量的子集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文