Decrease Periodicity of Time Series by Aggregation

DESCRIPTION:
Returns a shorter time series with observations that are the result of fun applied to a partition of the original time series.

USAGE:
aggregate(x, nf=1, fun=sum, ndeltat=1)

REQUIRED ARGUMENTS:
x:
a univariate or multivariate regular time series. Calendar time series will be coerced to regular. Missing values are allowed if fun accepts them.

OPTIONAL ARGUMENTS:
nf:
desired ("new") frequency for aggregated time series; must be a divisor of the frequency of x.
fun:
function to be used in performing aggregation. Most commonly, fun is either mean, to give the mean level for rate-like series, or fun is sum in order to compute totals.
ndeltat:
desired ("new") interval between observations; must be a divisor of the sampling interval deltat(x). The resulting series has frequency 1/ndeltat. If nf is given, this is ignored.

VALUE:
new time series with frequency nf. Each group of frequency(x)/nf observations is given to fun to create the aggregated value. (Incomplete cycles are ignored.)

DETAILS:
These are the "rts" and "cts" methods for the generic function aggregate.

SEE ALSO:
window , apply , rts , cts .

EXAMPLES:
aggregate(co2, 1, mean)  # yearly co2 level
aggregate(ship, 4, sum)  # quarterly manufacturing shipments
aggregate(ship, ndeltat=.25)  # same as above
aggregate(lynx, nf=frequency(x)/3, fun=mean) # aggregate lynx every 3 observations