agg: Tidy aggregate output

Description Usage Arguments Details Value See Also Examples

View source: R/agg.R

Description

Maintain a tidy data frame when aggregating results.

Usage

1

Arguments

...

Parameters passed to aggregate.

Details

When calling multiple functions in a vector, aggregate nests the output into the dependent variable(s). To maintain a tidy data frame, agg replicates the procedure of aggregate and unnests the result.

Value

Data frame.

See Also

https://github.com/robertschnitman/afp, aggregate, do.call, data.frame

Examples

1
2
3
4
5
6
# Compare
ms   <- function(x) c(m = mean(x), s = sd(x))
form <- formula(cbind(mpg, disp) ~ am + gear)

A <- aggregate(form, mtcars, ms) # str(A) # Nested mean & sd in mpg and disp.
B <- agg(form, mtcars, ms)       # str(B) # Unnested.

robertschnitman/afp documentation built on Aug. 9, 2020, 9:46 a.m.