Learn R Programming

geeLite (version 1.0.6)

aggr_by_freq: Aggregate Data by Frequency

Description

Aggregates data from a wide-format data frame according to a specified frequency and applies aggregation and post-processing functions.

Usage

aggr_by_freq(
  table,
  freq,
  prep_fun,
  aggr_funs,
  postp_funs,
  variable_name,
  preprocess_body
)

Value

A data frame in wide format with aggregated values.

Arguments

table

[mandatory] (data.frame) A wide-format data frame.

freq

[mandatory] (character) Specifies the frequency to aggregate the data.

prep_fun

[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().

aggr_funs

[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.

postp_funs

[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.

variable_name

[mandatory] (character) Name of the current variable.

preprocess_body

[mandatory] (character) Body of the prep_fun function.