Converts an object to a collection of features.
Usage
as_features(from, ...)
# S4 method for CompositionMatrix
as_features(from)
# S4 method for LogRatio
as_features(from)
Arguments
- from
A
CompositionMatrix
object.- ...
Currently not used.
Value
A data.frame
with all informations as extra columns.
See also
Other compositional data tools:
as_amounts()
,
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
get_totals(B)
#> [1] 223 260 276 253 249 312 138 264 271 205 146 176 312 246 297 234 401 136 281
#> [20] 367
## This allows to restore the source data
A2 <- as_amounts(B)
## Coerce to a data.frame
X <- data.frame(B)
head(X)
#> V1 V2 V3 V4 V5
#> S1 0.3183857 0.04484305 0.1793722 0.14798206 0.30941704
#> S2 0.3153846 0.16538462 0.3615385 0.11153846 0.04615385
#> S3 0.0942029 0.34420290 0.3115942 0.09057971 0.15942029
#> S4 0.2529644 0.23715415 0.2845850 0.13438735 0.09090909
#> S5 0.1325301 0.25301205 0.0562249 0.34939759 0.20883534
#> S6 0.2884615 0.18589744 0.2147436 0.24679487 0.06410256