Re: [Rd] Improve aggregate.default ...?

2009-05-09 Thread Gavin Simpson
On Sat, 2009-05-09 at 08:23 -0400, Gabor Grothendieck wrote: > Try this: > > > aggregate(dat["A"], dat["Group"], mean) > Group A > 1 1 0.4944810 > 2 2 0.4765412 > 3 3 0.4521068 > 4 4 0.4989000 Thanks Gabor. Ideally, aggregate.default should "work" whatever indexing one u

Re: [Rd] Improve aggregate.default ...?

2009-05-09 Thread Gabor Grothendieck
Try this: > aggregate(dat["A"], dat["Group"], mean) Group A 1 1 0.4944810 2 2 0.4765412 3 3 0.4521068 4 4 0.4989000 On Sat, May 9, 2009 at 8:14 AM, Gavin Simpson wrote: > Hi, > > I find it a bit annoying that aggregate.default forces the returned > object to loose the '

[Rd] Improve aggregate.default ...?

2009-05-09 Thread Gavin Simpson
Hi, I find it a bit annoying that aggregate.default forces the returned object to loose the 'name' of the variable aggregated, replacing it with 'x'. A brief example: > dat <- data.frame(A = runif(100), B = rnorm(100), + Group = gl(4, 25)) > with(dat, aggregate(A, by = list(Gr