
Last chance! 50% off unlimited learning
Sale ends in
An S4 class to represent an incidence (presence/absence) matrix.
IncidenceMatrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE,
dimnames = NULL)
an optional data vector (including a list or
expression
vector). Non-atomic classed R objects are
coerced by as.vector
and all attributes discarded.
the desired number of rows.
the desired number of columns.
logical. If FALSE
(the default) the matrix is
filled by columns, otherwise the matrix is filled by rows.
A dimnames
attribute for the matrix:
NULL
or a list
of length 2 giving the row and column
names respectively. An empty list is treated as NULL
, and a
list of length one as row names. The list can be named, and the
list names will be used as names for the dimensions.
Numeric values are coerced to logical
as by
as.logical
.
# NOT RUN {
# Create an incidence (presence/absence) matrix
# Data will be coerced with as.logical()
A <- IncidenceMatrix(data = sample(0:1, 100, TRUE, c(1, 0.3)),
nrow = 10, ncol = 10)
# Coerce to a co-occurrence matrix
B <- as(A, "OccurrenceMatrix")
# Create a count data matrix
C <- CountMatrix(data = sample(0:10, 100, TRUE),
nrow = 10, ncol = 10, byrow = TRUE)
# Coerce to presence/absence
D <- as(C, "IncidenceMatrix")
# Coerce to a co-occurrence matrix
E <- as(C, "OccurrenceMatrix")
# }
Run the code above in your browser using DataLab