Learn R Programming

tabula (version 1.0.0)

FrequencyMatrix-class: Frequency matrix

Description

An S4 class to represent a frequency matrix.

Usage

# S4 method for FrequencyMatrix
totals(x)

Arguments

x

A FrequencyMatrix object from which to extract element.

Methods (by generic)

  • totals: Returns the row sums (counts).

Slots

total

A numeric vector.

Details

To ensure data integrity, a FrequencyMatrix can only be created by coercion from a '>CountMatrix (see examples).

See Also

matrix

Other abundance matrix: CountMatrix-class

Examples

Run this code
# NOT RUN {
# Create a count data matrix
A1 <- CountMatrix(data = sample(0:10, 100, TRUE),
                  nrow = 10, ncol = 10, byrow = TRUE)

# Coerce counts to frequencies
B <- as(A1, "FrequencyMatrix")

# Row sums are internally stored before coercing to a frequency matrix
totals(B) # Get row sums

# This allows to restore the source data
A2 <- as(B, "CountMatrix")
all(A1 == A2)
# }

Run the code above in your browser using DataLab