aggregate_key {fabletools} | R Documentation |
Expand a dataset to include other levels of aggregation
Description
Uses the structural specification given in .spec
to aggregate a time
series. A grouped structure is specified using grp1 * grp2
, and a nested
structure is specified via parent / child
. Aggregating the key structure is
commonly used with forecast reconciliation to produce coherent forecasts over
some hierarchy.
Usage
aggregate_key(.data, .spec, ...)
Arguments
.data |
A tsibble. |
.spec |
The specification of aggregation structure. |
... |
< The value can be:
|
Details
This function is experimental, and is subject to change in the future.
The way in which the measured variables are aggregated is specified in a
similar way to how [dplyr::summarise()]
is used.
See Also
Examples
library(tsibble)
tourism %>%
aggregate_key(Purpose * (State / Region), Trips = sum(Trips))