Splits the data into subsets, computes summary statistics for each, and returns the result.
methods
## S4 method for signature 'CompositionMatrix'aggregate(x, by, FUN,..., simplify =TRUE, drop =TRUE)## S4 method for signature 'GroupedComposition'aggregate(x, FUN,..., simplify =TRUE)
Arguments
x: A CompositionMatrix object.
by: A vector or a list of grouping elements, each as long as the variables in x (see group()).
FUN: A function to compute the summary statistics.
...: Further arguments to be passed to FUN.
simplify: A logical scalar: should the results be simplified to a matrix if possible?
drop: A logical scalar indicating whether to drop unused combinations of grouping values.
Returns
A matrix.
Examples
## Data from Aitchison 1986data("slides")## Coerce to a compositional matrixcoda <- as_composition(slides)## Compositional mean by slideaggregate(coda, by = slides$slide, FUN = mean)## Metric variance by slideaggregate(coda, by = slides$slide, FUN = variance_total)