Dear List, I'll appreciate your help on this. I'm trying to create a variable as in "cumsum_y.cond1" below, which should compute the cumulative sum of "y" conditional on the value of cond==1.
set.seed(1) d <- data.frame(y= sample(c(0,1), 10, replace= T), cond= sample(c(0,1), 10, replace= T)) y cond cumsum_y.cond1 1 0 0 0 2 0 0 0 3 1 1 1 4 1 0 1 5 0 1 1 6 1 0 1 7 1 1 2 8 1 1 3 9 1 0 3 10 0 1 3 Thank you. Regards, Axel. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.