[R] zoo:rollapply by multiple grouping factors

Gabor Grothendieck ggrothendieck at gmail.com
Mon Apr 4 21:54:34 CEST 2011

On Mon, Apr 4, 2011 at 3:40 PM, Mark Novak <mnovak1 at ucsc.edu> wrote:
> Thank you very much Gabor!  It looks like that's gonna work wonderfully.  I
> didn't even know 'ave' existed.
> For others out there:  I only needed to add a comma:   dat[,c("Site",
> "Plot", "Sp")]

Actually, if dd is a data frame dd[, ix] and dd[ix] give the same result. e.g.

> dd <- data.frame(a = 1:3, b = 11:13, c = 21:23)
> identical(dd[, c("b", "c")], dd[c("b", "c")])
[1] TRUE

> Small follow up Q:  Is there any reason to use 'aggregate' vs. 'ave' in
> general?

aggregate reduces the data to fewer rows. ave adds a potentially
additional column to the original data.

Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

More information about the R-help mailing list