8
I would like to know how to count sequences of 1 within a vector containing only 0 and 1. For example, in the vector x <- c(1, 1, 0, 0, 1, 0, 1, 1)
, the count would give the vector (2, 1, 2)
, which counts the sequence of 2 "1", 1 "1" and finally 2 "1".
Thanks, Marcus! Thanks for your help.
– George
If the answer helped, consider vote and accept her.
– Marcus Nunes