I would like to know how to count sequences of 1 within a vector containing only 0 and 1. For example, in the x <- c(1, 1, 0, 0, 1, 0, 1, 1)
vector, the count would give the (2, 1, 2)
vector, which counts the sequence of 2 "1", 1 "1", and finally 2 "1".