Hi I'm trying to add up values in a vector since a zero value in R. I have a vector like this:
wdnew
[1] 1 0 0 1 1 0 0 1 1 1 1 1
And I want to create a new vector that counts the number of iterations or places since a zero value. If I did this properly I'd get a vector like this:
wdseq
[1] 1 0 0 1 2 0 0 1 2 3 4 5
This ought to be straightforward but I can't figure out how to generate the sequence, any suggestions? Thanks,