Last chance! 50% off unlimited learning
Sale ends in
Coerces an object to a CompositionMatrix
object.
as_composition(from, ...)# S4 method for numeric
as_composition(from)
# S4 method for matrix
as_composition(from)
# S4 method for data.frame
as_composition(
from,
parts = NULL,
groups = NULL,
autodetect = TRUE,
verbose = getOption("nexus.verbose")
)
A CompositionMatrix
object.
A matrix
or data.frame
to be coerced.
Currently not used.
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.
An integer
giving the index of the column to be used to
group the samples. If NULL
(the default), no grouping is stored.
A logical
scalar: should numeric
variables be
automatically used as compositional parts?
A logical
scalar: should R report extra information
on progress?
N. Frerebeau
See vignette("nexus")
.
Other compositional data tools:
as_amounts()
## 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)
Run the code above in your browser using DataLab