aggregate: Compute Summary Statistics of Data Subsets

aggregateR Documentation

Compute Summary Statistics of Data Subsets

Description

Splits the data into subsets, computes summary statistics for each, and returns the result.

Usage

## S4 method for signature 'CompositionMatrix'
aggregate(x, by, FUN, ..., simplify = TRUE, drop = TRUE)

Arguments

x

A CompositionMatrix object.

by

A vector or a list of grouping elements, each as long as the variables in x. The elements are coerced to factors before use (in the sense that interaction(by) defines the grouping).

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.

Value

A matrix.

Author(s)

N. Frerebeau

See Also

Other statistics: condense(), covariance(), dist, mahalanobis(), margin(), mean(), pip(), quantile(), scale(), variance(), variance_total(), variation()

Examples

## Data from Aitchison 1986
data("slides")

## Coerce to a compositional matrix
coda <- as_composition(slides)

## Compositional mean by slide
aggregate(coda, by = slides$slide, FUN = mean)

## Metric variance by slide
aggregate(coda, by = slides$slide, FUN = variance_total)

nexus documentation built on Sept. 11, 2024, 6:43 p.m.