(sorry, really don't know how to better phrase this question)
I have a column "have" with 1s and 0s. I want to create a new column "want" where, each time a 1 has occurred, the value of 0 increases to 2, then 3, then 4, etc. 0 should never be 1.
Example:
data <- data.frame(have = (c('0', '0', '0', '0', '1', '0', '1', '0', '0', '1')),
want = (c('0', '0', '0', '0', '1', '2', '1', '3', '3', '1')))