I just saw a little mistake in my last post: Totally in the end, last line of the last loop, results$depth[,u] [t-1] should be results$newdepth[,u] [t-1]. My apologies.
for (u in 1:91) { results$newdepth [,u]<- results$depth [,u] for (t in 2:60) { results$newdepth[,u][t] <- results$newdepth[,u] [t-1] }} -- View this message in context: http://r.789695.n4.nabble.com/Accomplishing-a-loop-on-multiple-columns-tp4284974p4289248.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.