Say I have a logical value like this
rex <- c(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, NA)
How do I create a counter which will only count for the TRUE and will group consecutive repetitions as the same value in the counter. ex. to have something like this:
1, NA, 2,2,NA, 3, NA