如何分辨一个向量中的内容而不是另一个向量? [英] How to tell what is in one vector and not another?

查看:53
本文介绍了如何分辨一个向量中的内容而不是另一个向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 matlab 中,有一种方法可以找到一个向量中的值,而不是另一个向量中的值.

In matlab there is a way to find the values in one vector but not in the other.

例如:

x <- c(1,2,3,4)
y <- c(2,3,4)

是否有任何函数可以告诉我 x 中不在 y 中的值是 1?

is there any function that would tell me that the value in x that's not in y is 1?

推荐答案

你可以使用setdiff()(设置差异)函数:

you can use the setdiff() (set difference) function:

> setdiff(x, y)
[1] 1

这篇关于如何分辨一个向量中的内容而不是另一个向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆