as_composition function

Coerce to a Closed Compositional Matrix

Coerce to a Closed Compositional Matrix

Coerces an object to a CompositionMatrix object. methods

as_composition(from, ...) ## S4 method for signature 'numeric' as_composition(from) ## S4 method for signature 'matrix' as_composition(from) ## S4 method for signature 'data.frame' as_composition( from, parts = NULL, groups = NULL, autodetect = TRUE, verbose = getOption("nexus.verbose") )

Arguments

  • from: A matrix or data.frame to be coerced.
  • ...: Currently not used.
  • parts: A vector giving the index of the column to be used a compositional parts. If NULL and autodetect is TRUE (the default), all numeric columns will be used.
  • groups: An integer giving the index of the column to be used to group the samples. If NULL (the default), no grouping is stored.
  • autodetect: A logical scalar: should numeric variables be automatically used as compositional parts?
  • verbose: A logical scalar: should report extra information on progress?

Returns

A CompositionMatrix object.

Details

See vignette("nexus").

Examples

## Create a count matrix A1 <- matrix(data = sample(1:100, 100, TRUE), nrow = 20) ## Coerce to compositions B <- as_composition(A1) ## Row sums are internally stored before coercing to relative frequencies totals(B) ## This allows to restore the source data A2 <- as_amounts(B) ## Coerce to a data.frame X <- as.data.frame(B) head(X)

See Also

Other compositional data tools: as_amounts()

Author(s)

N. Frerebeau