Learn R Programming

nexus (version 0.3.0)

as_amounts: Coerce to Amounts

Description

Coerce to Amounts

Usage

as_amounts(from, ...)

# S4 method for CompositionMatrix as_amounts(from)

Value

A numeric

matrix.

Arguments

from

A CompositionMatrix object.

...

Currently not used.

Author

N. Frerebeau

See Also

Other compositional data tools: as_composition()

Examples

Run this code
## 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 <- data.frame(B)
head(X)

Run the code above in your browser using DataLab