
Last chance! 50% off unlimited learning
Sale ends in
An S4 class to represent a relative frequency matrix.
# S4 method for FrequencyMatrix
totals(x)
A FrequencyMatrix
object from which to extract element.
totals
: Returns the row sums (counts).
total
A numeric
vector.
To ensure data integrity, a FrequencyMatrix
can only be created by
coercion from a '>CountMatrix (see examples).
Other abundance matrix: CountMatrix-class
,
OccurrenceMatrix-class
# 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)
# Coerce to a co-occurrence matrix
C <- as(B, "OccurrenceMatrix")
# }
Run the code above in your browser using DataLab