mat2list {mefa}R Documentation

Matrix Manipulation Tools

Description

Converts a matrix to a list, calculates matrix fill, or exclude rows/columns with certain rox/column sums.

Usage

mat2list(x, MARGIN = 1)
mfill(x)
rdrop(x, cutoff = 0)
cdrop(x, cutoff = 0)

Arguments

x A vector or matrix to be converted.
MARGIN Margin in c(1, 2), indicating respectively rows or colums to be listed.
cutoff Numeric, exclude rows/columns with sums <= cutoff.

Value

mat2list returns a list of length nrow(x) or ncol(x) depending on MARGIN. Elements are rows/columns of x. Dimnames are retained as names.
mfill returns a single number with the matrix fill value.
rdrop and cdrop return the original matrix but excluding rows (rdrop), or columns (cdrop) that has sum <= cutoff. Excluded row/colum numbers and specifications are stored in the "exclude" attribute.

Author(s)

P\'eter S\'olymos, solymos@ualberta.ca

References

S\'olymos P. (2008) mefa: an R package for handling and reporting count data. Community Ecology 9, 125–127.

S\'olymos P. (2009) Processing ecological data in R with the mefa package. Journal of Statistical Software 29(8), 1–28. http://www.jstatsoft.org/v29/i08/

http://mefa.r-forge.r-project.org/

Examples

x <- matrix(1:12, 3, 4)
rownames(x) <- letters[1:3]
colnames(x) <- LETTERS[1:4]
mat2list(x, 1)
mat2list(x, 2)
x[2, ] <- 0
x[, 2] <- 0
mfill(x)
mfill(x) == sum(x > 0) / prod(dim(x))
rdrop(x)
cdrop(x)
cdrop(x, cutoff = 5)
cdrop(x, cutoff = 22) # be careful

[Package mefa version 3.1-4 Index]