Is between two elements in R -
this question has answer here:
i want check elements of vector
= c(0.15, 1.5, 11, 15, 22)
is between elements of vector
b =c(0, 3, 5, 10, 20, 25)
which means second element of vector a
between second , third elements of vector b
or not, ... not checkig first element of a
.
how can in r?
the following gives want:
larger <- a[1:length(a)] > b[1:(length(b)-1)] smaller <- a[1:length(a)] < b[2:length(b)] between <- larger & smaller between[1] <- false a[between]
first check whether or not elements in smaller corresponding elements in b. select if smaller next element in b. combine both , remoe unwanted first. tada.
Comments
Post a Comment