Hi  everyone

 

Do you know about any possibility in R to check for consecutive numbers in
vectors? That is, I do not only want to count the number of observations in
total (which can be done table(x)), but I also want to count for instance
how many times that vector contains a certain number consecutively.

 

For example in the following vector x the number "1" appears 7 times.
However, I want to check for instance how many times two consecutive 1's
appear in the vector, which would actually be two times the case in the
below vector.

 

> x=c(1,1,3,4,9,1,9,1,5,4,5,2,1,1,1,6)

 

Any ideas for this issue?

 

Thanks, S.B.


	[[alternative HTML version deleted]]

