Hello all I have the data frame with this:
ID DATETIME TRN TRN_S 1 1192756 2010-06-23 15:39:07 13.420 0.2236667 2 1192757 2010-06-23 15:40:07 13.805 0.2300833 3 1192758 2010-06-23 15:41:07 13.860 0.2310000 4 1192759 2010-06-23 15:42:07 13.750 0.2291667 5 1192760 2010-06-23 15:43:07 13.530 0.2255000 6 1192761 2010-06-23 15:44:07 13.805 0.2300833 Now, I would like to plot a graph with DATETIME and the accumulated TRN_S. I can run a while loop like this: accumulated_trns <- 0 last_value <-length(data$TRN_S) while (i < last_value) { acc_trns <- acc_trns + data$TRN_S[i] data$accumulated_trns[i] <- acc_trns i <- i + 1 } data$accumulated_trns[i] <- acc_trns plot(data$DATETIME, data$accumulated_trns) This is slow and demanding on the computer. There must be a better way to accumulate values! Any suggestion greatly appreciated. [[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.