Aggregates data from a wide-format data frame according to a specified frequency and applies aggregation and post-processing functions.
aggr_by_freq(
table,
freq,
prep_fun,
aggr_funs,
postp_funs,
variable_name,
preprocess_body
)A data frame in wide format with aggregated values.
[mandatory] (data.frame) A wide-format data frame.
[mandatory] (character) Specifies the frequency to aggregate the data.
[mandatory] (function) Pre-processing function used during
daily expansion prior to aggregation. This is guaranteed to be a function
because read_db() replaces NULL with linear_interp().
[optional] (function or list) Aggregation function(s) used
when aggregating to freq.
If a single function is provided, it is used for all variables.
If an unnamed list of functions is provided, all functions are
applied to all variables (treated as default).
If a named list is provided, names must be variable names (as
returned by fetch_vars) and/or "default"; named entries
override the default for those variables.
[optional] (function or list or "external") Post-
processing function(s) applied after aggregation.
If a single function or NULL is provided, it is used for
all variables as default.
If an unnamed list of functions is provided, all are applied to
all variables (treated as default).
If a named list is provided, names must be variable names (as
returned by fetch_vars) and/or "default"; named entries
override the default for those variables.
If "external", functions are loaded from postp/.
Default is NULL.
[mandatory] (character) Name of the current variable.
[mandatory] (character) Body of the prep_fun
function.