[英]Check the elements of a vector in R
I would like to check the elements of the vector 我想检查一下矢量的元素
x = c(0.0153, 0.1352, 0.2820, 0.4629, 0.6944, 0.8919,
1.0638, 1.2458, 1.4068, 1.5969, 1.7700, 1.9024,
2.0144, 2.1143, 2.2286, 2.3453, 2.5096, 2.7499,
3.0299, 3.5061)
is between the elements of the vector 是在向量的元素之间
y =c(0.0000, 0.0917, 0.2174, 0.3087, 0.4151, 0.8984,
1.0921, 1.1579, 1.3803, 1.3806, 1.6234, 1.8682,
2.0565, 2.2194, 2.285, 2.4183, 2.4463, 2.512,
2.7964, 3.0766, 3.5061)
which means that is the first element of vector x
between the first and second elements of the vector y
or not, ... but not checkig the last element x
. 这意味着是向量的第一元素
x
的向量的第一和第二元件之间y
与否,...但不checkig的最后一个元素x
。
Is there anymethod to solve it? 有什么方法可以解决吗?
you could probably remove the for loop 你可以删除for循环
x[(x>y[-length(y)])&(x<y[-1])]
and add the last x value. 并添加最后的x值。 Im not clear if you want the last x or not?
我不清楚你是否想要最后一个x?
or 要么
x[!((x-y[-length(y)])*(y[-1]-x)<0)]
if you want the last x 如果你想要最后的x
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.