aggregate_index {fabletools} | R Documentation |
Expand a dataset to include temporal aggregates
Description
Usage
aggregate_index(.data, .window, ..., .offset = "end", .bin_size = NULL)
Arguments
.data |
A tsibble. |
.window |
Temporal aggregations to include. The default (NULL) will automatically identify appropriate temporal aggregations. This can be specified in several ways (see details). |
... |
< The value can be:
Returning values with size 0 or >1 was
deprecated as of 1.1.0. Please use |
.offset |
Offset the temporal aggregation windows to align with the start or end of the data. If FALSE, no offset will be applied (giving common breakpoints for temporal bins.) |
.bin_size |
Temporary. Define the number of observations in each temporal bucket |
Details
This feature is very experimental. It currently allows for temporal aggregation of daily data as a proof of concept.
The aggregation .window
can be specified in several ways:
A character string, containing one of "day", "week", "month", "quarter" or "year". This can optionally be preceded by a (positive or negative) integer and a space, or followed by "s".
A number, taken to be in days.
A
difftime
object.
Examples
library(tsibble)
pedestrian %>%
# Currently only supports daily data
index_by(Date) %>%
dplyr::summarise(Count = sum(Count)) %>%
# Compute weekly aggregates
fabletools:::aggregate_index("1 week", Count = sum(Count))