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 matrixA1 <- matrix(data = sample(1:100,100,TRUE), nrow =20)## Coerce to compositionsB <- as_composition(A1)## Row sums are internally stored before coercing to relative frequenciestotals(B)## This allows to restore the source dataA2 <- as_amounts(B)## Coerce to a data.frameX <- as.data.frame(B)head(X)