Skip to contents

Converts an object to a collection of features.

Usage

as_features(from, ...)

# S4 method for CompositionMatrix
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()

Author

N. Frerebeau

Examples

## Create a count matrix
A1 <- matrix(data = as.numeric(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] 222 134 202 295 234 373 210 237 237 308 211 342 140 340 218 374 239 210 232
#> [20] 238

## 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.23423423 0.24324324 0.12162162 0.21171171 0.1891892
#> S2 0.08208955 0.21641791 0.18656716 0.37313433 0.1417910
#> S3 0.12871287 0.36633663 0.08415842 0.02475248 0.3960396
#> S4 0.19661017 0.03389831 0.32203390 0.12203390 0.3254237
#> S5 0.08974359 0.04273504 0.30341880 0.22649573 0.3376068
#> S6 0.14745308 0.18498660 0.25201072 0.24128686 0.1742627