aggregate: Aggregation of time series

View source: R/timeseries.R

aggregateR Documentation

Aggregation of time series

Description

Makes a frequency change of this series.

Usage

aggregate(
  s,
  nfreq = 1,
  conversion = c("Sum", "Average", "First", "Last", "Min", "Max"),
  complete = TRUE
)

Arguments

s

the input time series.

nfreq

the new frequency. Must be la divisor of the frequency of s.

conversion

Aggregation mode: sum ("Sum"), average ("Average"), first observation ("First"), last observation ("Last"), minimum ("Min"), maximum ("Max").

complete

Boolean indicating if the observation for a given period in the new series is set missing if some data in the original series are missing.

Value

A new time series of frequency nfreq.

Examples

s <- ABS$X0.2.09.10.M
# Annual sum
aggregate(s, nfreq = 1, conversion = "Sum") # first and last years removed
aggregate(s, nfreq = 1, conversion = "Sum", complete = FALSE)
# Quarterly mean
aggregate(s, nfreq = 4, conversion = "Average")

palatej/rjd3toolkit documentation built on Oct. 30, 2024, 10:46 p.m.