Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

aggregate.tis

Compute Summary Statistics of Time Series Subsets


Description

Splits the data into subsets, computes summary statistics for each, and returns the result in a convenient form.

Usage

## S3 method for class 'tis'
aggregate(x, FUN = sum, ...)

Arguments

x

a tis time series.

FUN

a scalar function to compute the summary statistics which can be applied to all data subsets.

...

further arguments passed to aggregate.ts

Details

This is a method for the generic aggregate function.

The aggregate function was really designed for ts objects, not tis objects which may or may not meet the assumptions embedded in the function. The convert function is better suited for tis series.

aggregate.tis calls as.ts on it's x argument, then passes that and all other arguments on to aggregate.ts and then turns the result back into a tis series. If there is a local version of aggregate.ts that can be found by exists("aggregate.ts", envir = globalenv()), it will be used in preference to the function in package:stats.

Value

the tis object returned by as.tis() called on the ts object returned by aggregate.ts.

See Also

Examples

z <- tis(1:24, start = latestJanuary()) ## a monthly series
aggregate(z, nf = 4, FUN = mean)        ## quarterly average
aggregate(z, nf = 1, FUN = function(x) x[length(x)]) ## December is annual level

tis

Time Indexes and Time Indexed Series

v1.38
Unlimited
Authors
Jeff Hallman <jeffhallman@gmail.com>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.