I've sent last message only to Titus. Sorry :) Below my proposition: Instead of aggregate, try summaryBy from doBy package. It's much faster. And this package made my life easier :)
try: summaryBy(dur+x~index, data=d, FUN=c(sum, mean)), but index should be in data.frame as I remember. I haven't checked this code, so let me know, if it doesn't work. 2009/12/8 Titus von der Malsburg <malsb...@gmail.com>: > 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. > -- Marek ______________________________________________ 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.