ts_frequency {tsbox} | R Documentation |
Change Frequency
Description
Changes the frequency of a time series. By default, incomplete periods of regular series are omitted.
Usage
ts_frequency(
x,
to = c("year", "quarter", "month", "week", "day", "hour", "min", "sec"),
aggregate = "mean",
na.rm = FALSE
)
Arguments
x |
ts-boxable time series, an object of class |
to |
desired frequency, either a character string ( |
aggregate |
character string, or function. Either |
na.rm |
logical, if |
Details
The tempdisagg package
can convert low frequency to high frequency data and
has support for ts-boxable objects. See
vignette("hf-disagg", package = "tempdisagg")
.
Value
a ts-boxable time series, with the same class as the input.
Examples
ts_frequency(cbind(mdeaths, fdeaths), "year", "sum")
ts_frequency(cbind(mdeaths, fdeaths), "quarter", "last")
ts_frequency(AirPassengers, 4, "sum")
# Note that incomplete years are omited by default
ts_frequency(EuStockMarkets, "year")
ts_frequency(EuStockMarkets, "year", na.rm = TRUE)