I have a sequence of 0s and 1s in this manner:
xx <- c(1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1)
I want to make a vector that accumulates the streak of the zeroes and adds the accumulated streak to the next possible value 1. The result in this specific vector should be:
yy <- c(1, 1, 1, 0, 0, 3, 0, 2, 0, 0, 0, 4)
What is the fastest and most efficient way to do this in R?