
Last chance! 50% off unlimited learning
Sale ends in
An S4 class to represent a co-occurrence matrix.
A co-occurrence matrix is a symetric matrix with zeros on its main diagonal, which works out how many times (expressed in percent) each pairs of taxa occur together in at least one sample.
Other abundance matrix: CountMatrix-class
,
FrequencyMatrix-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