Skip to main content

interp_aggregate

Function interp_aggregate 

Source
fn interp_aggregate(
    positional: &[RValue],
    named: &[(String, RValue)],
    context: &BuiltinContext<'_>,
) -> Result<RValue, RError>
Expand description

Aggregate data by groups, applying a function to each group.

Supports two calling conventions: aggregate(x, by, FUN) — x is a vector/matrix, by is a list of grouping vectors aggregate(formula, data, FUN) — formula interface (y ~ x, data=df, FUN=mean)

@param x numeric vector or data frame column to aggregate, or a formula @param by list of grouping vectors (each same length as x), or data frame (formula interface) @param FUN function to apply to each group @param data data frame (named argument, formula interface) @return data frame with grouping columns and aggregated value columns