Coerce to Amounts
Arguments
- from
A
CompositionMatrix
object.- ...
Currently not used.
See also
Other compositional data tools:
as_composition()
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)
#> [1] 245 264 258 162 253 285 223 369 255 279 190 246 344 381 84 231 240 356 195
#> [20] 145
## This allows to restore the source data
A2 <- as_amounts(B)
## Coerce to a data.frame
X <- as.data.frame(B)
head(X)
#> V1 V2 V3 V4 V5
#> S1 0.13469388 0.1673469 0.15918367 0.33877551 0.2000000
#> S2 0.13636364 0.3106061 0.04166667 0.21212121 0.2992424
#> S3 0.02713178 0.3643411 0.16279070 0.20155039 0.2441860
#> S4 0.14197531 0.1172840 0.24691358 0.35185185 0.1419753
#> S5 0.34782609 0.3003953 0.05928854 0.06719368 0.2252964
#> S6 0.11929825 0.1789474 0.28771930 0.30526316 0.1087719