An S4 class to represent an incidence (presence/absence) matrix.

IncidenceMatrix(data = FALSE, nrow = 1, ncol = 1, byrow = FALSE,
dimnames = NULL, ...)

## Arguments

data 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. additional arguments to be passed to or from methods.

TODO

## Details

Numeric values are coerced to logical as by as.logical.

## Matrix ID

When a matrix is first created, an identifier is generated (UUID v4). This ID is preserved when coercing to another class. Thus, the object ID is unique within the same class, but two objects of different classes can have the same ID. This makes it possible to identify objects representing the same initial data and associate them with the results of specific computations (e. g. seriation).

## Get and set

In the code snippets below, x is a *Matrix object.

get_id(x)

Get the ID of x.

## Access

In the code snippets below, x is a *Matrix object.

dim(x)

Returns the dimension of x.

nrow(x)

Returns the number of rows present in x.

ncol(x)

Returns the number of columns present in x.

dimnames(x), dimnames(x) <- value

Retrieves or sets the row dimnames of x according to value.

rownames(x), rownames(x) <- value

Retrieves or sets the row names of x according to value.

colnames(x), colnames(x) <- value

Retrieves or sets the column names of x according to value.

## Subset

In the code snippets below, x is a *Matrix object.

x[i, j]

Extracts elements selected by subscripts i and j. Indices are numeric, integer or character vectors or empty (missing) or NULL. Numeric values are coerced to integer as by as.integer (and hence truncated towards zero). Character vectors will be matched to the name of the elements. An empty index (a comma separated blank) indicates that all entries in that dimension are selected. Returns an object of the same class as x.

x[[i]]

Extracts informations from a slot selected by subscript i. i should be one of "id" or NULL.

Other matrix: CountMatrix-class, FrequencyMatrix-class, LogicalMatrix-class, Matrix-class, NumericMatrix-class, OccurrenceMatrix-class, SimilarityMatrix-class, coerce

## Examples

## 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_occurrence(A)
## 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_incidence(C)