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

## Arguments

- x
A CompositionMatrix object.

- by
A

`character`

string specifying the grouping element. It must be one of "`samples`

" or "`groups`

". Any unambiguous substring can be given.- FUN
A

`function`

to compute the summary statistics.- ...
Further arguments to be passed to

`FUN`

.

## Value

A `matrix`

.

## See also

Other statistics:
`covariance`

,
`dist()`

,
`mahalanobis()`

,
`mean()`

,
`variation()`

## Examples

```
## Create a data.frame
X <- data.frame(
samples = c("A", "A", "A", "B", "B", "B", "C", "C", "C"),
groups = c("X", "X", "X", "X", "X", "X", "Y", "Y", "Y"),
Ca = c(7.72, 7.32, 3.11, 7.19, 7.41, 5, 4.18, 1, 4.51),
Fe = c(6.12, 5.88, 5.12, 6.18, 6.02, 7.14, 5.25, 5.28, 5.72),
Na = c(0.97, 1.59, 1.25, 0.86, 0.76, 0.51, 0.75, 0.52, 0.56)
)
## Coerce to a compositional matrix
Y <- as_composition(X)
## Compositional mean by sample
aggregate(Y, by = "samples", FUN = mean)
#> Warning: No observations are repeated.
#> Ca Fe Na
#> A 0.4468157 0.4539051 0.09927924
#> B 0.4746506 0.4742013 0.05114805
#> C 0.3067545 0.6238351 0.06941036
## Compositional mean by group
aggregate(Y, by = "groups", FUN = mean)
#> Ca Fe Na
#> X 0.4625002 0.4659342 0.07156562
#> Y 0.3067545 0.6238351 0.06941036
```