I have a binary vector and I want to count how many sequences of 1's I've got. So that if I have a vector like:
bin <- c(1,1,0,1,1,1,1,0,0,0,1,0,1,1,0,0,1,1,1)
I would get 5
. I haven't found any existing functions that could do this, anyone got any good tips on how one could write one? I don't know how to build the "counter" when the sequences all have different lengths.