| as.matrix | R Documentation |
Coerce to a Matrix
## S4 method for signature 'NumericMatrix'
as.matrix(x, ...)
x |
An R object (typically, a |
... |
Currently not used. |
A matrix.
June 2026: aperm.default() now copy attributes, this change how apply() works on classed objects. The simplest "fix" is to add an aperm() S3 method for the class which drops attributes as aperm.default() previously did. Alternatively, one could also consider providing as.matrix()/as.array() methods which change to standard matrix/array.
N. Frerebeau
## Create a count matrix
A1 <- matrix(data = sample(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.