This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: cts, data.frame, rts.
aggregate(x, ...) aggregate.default(x, ...)
Each method accepts different arguments, see aggregate.data.frame, aggregate.rts, or aggregate.cts for details.
# compute 50 year averages of sunspot numbers aggregate(sunspots, ndeltat = 50, fun = mean)# gives the following results: [1] 53.96067 39.95750 45.09283 47.93400 start deltat frequency 1750 50 0.02
# compute regional averages of demographic data aggregate(state.x77[,2:4], list(Region = state.region), FUN = mean)
Region Income Illiteracy Life.Exp 1 Northeast 4570.222 1.000000 71.26444 2 South 4011.938 1.737500 69.70625 3 North Central 4611.083 0.700000 71.76667 4 West 4702.615 1.023077 71.23462