length between 2 values

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-04-17T05:57:34Z Indexed on 2010/04/17 6:03 UTC
Read the original article Hit count: 182

Filed under:

In R, what is the most efficient way to count the length between 2 values. for example, i have vector x , which are all randomly choose from 1 to 100, how can i find out the length between the first"2" and first"40", x=(1,2,3,4,5,6,7,40,1,2,3,21,4,1,23,4,43,23,4,12,3,43,5,36,3,45,12,31,3,4,23,41,23,5,53,45,3,7,6,36) for this vector, the answer should be 5 and 6

© Stack Overflow or respective owner

Related posts about r