On 13-08-2013, at 18:46, jsf1982 <jamie.free...@ucl.ac.uk> wrote: > Hi, > Many apologies for the simplicity (hopefully!) of this request - I can't > find it on the forum, but it may have been asked in the past. > > I have a data frame consisting of ~2000 rows. I simply want to take the > average of the first 6, then the next 6, then the next 6 until the end of > the table. > The command > > mean(mole[1:6,c("PercentPI")]) > > gets me the first 6 rows (column is PercentPI), but I don't know how to > increase the rows incrementally.
Something like this N <- 27 dd <- data.frame(A=rnorm(1:N),index=gl(6,6,N)) aggregate(dd$A,by=list(dd$index),mean) Berend ______________________________________________ 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.