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? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -