On Tue, Dec 8, 2009 at 5:19 PM, Nikhil Kaza <nikhil.l...@gmail.com> wrote: > I suppose that is true, but the example data seem to suggest that it is > sorted by rt.
I was not very clear on that. Sorry. > d$count <- 1 > a <- with(d, aggregate(subset(d, select=c("dur", "x", "count"), > list(rt=rt,tid=tid,mood=mood,roi=roi), sum)) > a$x <- a$x/a$count This is neat! > But it would still be nice to get a generic way that uses different > functions on different columns much like excel's pivot table. I guess the most straight-forward thing would be to extend aggregate to also accept instead of a FUN a list of FUNs where the first is applied to value of the first column of x (the data frame), the second to the second column, and so on. Titus ______________________________________________ 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.