mefaTables {mefa}R Documentation

Subsetting and Ordering of Related Data Tables

Description

This function is called by the mefa function to subset the community data matrix and the related data frames, but can be applied more generally for subsetting and ordering.

Usage

mefaTables(xtab, dframe, margin, index = NULL,
drop.index = FALSE, xtab.fixed = TRUE)

Arguments

xtab a data matrix.
dframe a data frame.
margin margin of the xtab matrix to use row (margin = 1) or column (margin = 2) names in comparison with the rownames of dframe.
index if NULL rownames are used directly, else it can be used to set which column of dframe should be used as rowname and for comparison.
drop.index logical, should the index column of dframe be deleted (if index != NULL).
xtab.fixed logical, if TRUE the xtab matrix is left intact, and dframe is subsetted accordingly. If FALSE, both xtab and dframe are subsetted, and returned values are based on the the intersect of the compared names.

Value

Returns a list with elements xtab (matrix) and dtab (data frame), corresponding to the subsetted xtab and dframe data sets, respectively. Original column and row orderings in the input matrix xtab are preserved.

Author(s)

Péter Sólymos, solymos@ualberta.ca

References

Sólymos P. 2008. mefa: an R package for handling and reporting count data. Community Ecology 9, 125–127.

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

See Also

mefa

Examples

x <- matrix(rpois(20,1), 5, 4)
## Note the reverse alphabetical names
rownames(x) <- letters[5:1]
x
f <- data.frame(matrix(rnorm(30), 10, 3))
rownames(f) <- letters[1:10]
f
## Reverse alphabetical names preserved
mefaTables(x, f, 1)
## Now result is the intersect
rownames(f) <- letters[3:12]
mefaTables(x, f, 1, xtab.fixed = FALSE)

[Package mefa version 3.0-0 Index]