Here are two solutions. In both we break up DF into rows
which start with 1.
In solution #1 we create a new data frame with the required sequence
for A and zeros for B and then we fill it in.
In solution #2 we convert each set of rows to a zoo object z
where column A is the times and B is the
Gabor,
Thanks a lot for the help. The 1st method works fine. In 2nd method I am
getting following error.
do.call(rbind, by(DF, cumsum(DF$A == 1), f))
Error in zoo(, time(as.ts(z)), z, fill = 0) :
unused argument(s) (fill ...)
Unable to figure out the cause.
Thanks,
I did run it so I am not sure how the error crept in. Anyways,
I have fixed it and a corrected version is below.
---
Here are two solutions. In both we break up DF into rows
which start with 1.
In #1 we create a new data frame with the required sequence
for A and zeros for B and then we fill