CountMatrix-class: Count matrix

Description Usage Arguments Details Note Author(s) See Also Examples

Description

An S4 class to represent a count matrix.

Usage

1
2
CountMatrix(data = NA, 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.

nrow

the desired number of rows.

ncol

the desired number of columns.

byrow

logical. If FALSE (the default) the matrix is filled by columns, otherwise the matrix is filled by rows.

dimnames

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.

Details

Numeric values are coerced to integer as by as.integer (and hence truncated towards zero).

Note

This class extends the base matrix.

Author(s)

N. Frerebeau

See Also

matrix

Other abundance matrix: FrequencyMatrix-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 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)

nfrerebeau/tabula documentation built on Feb. 11, 2019, 9:16 a.m.