Check the element of a vetcor is between the element of second vector in R -


this question has answer here:

i have 2 vectors. want check first element of first vector between first , second element of second vector , check second element of first vector between third , forth element of second vector ,.....how can in r?

for example, if have tow vectors

   = c(1.5, 2, 3.5)    b = c(1, 2, 3, 5, 3, 8) 

the final result in r should 1.5 true , 3.5 true , 2 false.

here's 1 way.

s <- seq_along(a)   b[s] < a[s] & a[s] < b[s+1] # [1]  true false  true 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -