I have a vector, for example
ind <- c(TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)
and I want to count the number of subsequent "TRUE" values, whereas the counting should start from 1 if there was a "FALSE" value between a block of subsequent "TRUE" values. The result for the example above should be
result <- c(1,0,1,2,0,0,0,1,2,3,0)
Any ideas how to do this nicely?