Posts by George • 83 points
1 post
-
8
votes1
answer514
viewsQ: Count sequences of 1 within vector in R
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),…