CompositionMatrix-class: Compositional Matrix

CompositionMatrix-classR Documentation

Compositional Matrix

Description

An S4 class to represent compositional data.

Slots

totals

A numeric vector to store the absolute row sums (before the closure of the compositions).

groups

A factor vector to store the group names.

Coerce

In the code snippets below, x is a CompositionMatrix object.

as.data.frame(x)

Coerces to a data.frame.

Subset

In the code snippets below, x is a CompositionMatrix object.

x[i, j]

Extract parts of a matrix (see [).

Note

This class inherits from matrix.

Author(s)

N. Frerebeau

See Also

as_composition()

Other classes: LogRatio-class, LogicalMatrix-class, NumericMatrix-class, OutlierIndex-class

Examples

## Data from Aitchison 1986
data("hongite")

## Coerce to compositional data
coda <- as_composition(hongite)

## codaccess
dim(coda) # Get the matrix dimensions
row(coda) # Get the row indexes
col(coda, as.factor = TRUE) # Get the column indexes
nrow(coda) # Get the number of rows
ncol(coda) # Get the number of columns
dimnames(coda) # Get the dimension names
rownames(coda) <- LETTERS[1:25] # Set the row names
rownames(coda) # Get the rownames
colnames(coda) <- letters[21:25] # Set the column names
colnames(coda) # Get the column names

nexus documentation built on Sept. 11, 2024, 6:43 p.m.