Skip to contents

Splits the data into subsets and computes compositional mean for each.

Usage

condense(x, ...)

# S4 method for CompositionMatrix
condense(x, by = get_samples(x), ...)

Arguments

x

A CompositionMatrix object.

...

Further arguments to be passed to mean().

by

A vector of grouping elements, as long as the variables in x.

Value

A CompositionMatrix object.

See also

Author

N. Frerebeau

Examples

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

## Coerce to a compositional matrix
coda <- as_composition(slides, sample = 2, group = 1)

## Compositional mean by sample
condense(coda, by = get_samples(coda))
#> <CompositionMatrix: 5 x 7>
#>      quartz microcline plagioclass    biotite   muscovite     opaques
#> A 0.2591344  0.3553997   0.3335045 0.02654833 0.013683701 0.007173544
#> B 0.2703079  0.3526640   0.3239803 0.03482515 0.008977167 0.006667495
#> C 0.2772923  0.3535327   0.3149545 0.03107089 0.011128347 0.007732587
#> D 0.2757090  0.3548635   0.3138702 0.03298438 0.010338266 0.009093408
#> E 0.2794701  0.3474061   0.3231178 0.02962410 0.010892785 0.006494703
#>    nonopaques
#> A 0.004555830
#> B 0.002578014
#> C 0.004288649
#> D 0.003141288
#> E 0.002994409

## Compositional mean by group
condense(coda, by = get_groups(coda))
#> <CompositionMatrix: 5 x 7>
#>       quartz microcline plagioclass    biotite   muscovite     opaques
#> A1 0.2680804  0.3506615   0.3267723 0.03302334 0.010447298 0.006724201
#> A2 0.2831265  0.3509840   0.3161602 0.02767572 0.012826283 0.006955211
#> A3 0.2633293  0.3574333   0.3199675 0.03984005 0.009170492 0.008472383
#> A4 0.2725459  0.3590486   0.3181972 0.02652094 0.009552583 0.008424043
#> A5 0.2741411  0.3450908   0.3273973 0.02900410 0.013085565 0.006529511
#>     nonopaques
#> A1 0.004290959
#> A2 0.002272084
#> A3 0.001786999
#> A4 0.005710815
#> A5 0.004751617