as.data.frame.mefa {mefa}R Documentation

Convert an Object of Class 'mefa' Into 'data.frame'

Description

The function converts parts of a 'mefa' obect into a data frame.

Usage

## S3 method for class 'mefa':
as.data.frame(x, ..., fun, name, make.unique = FALSE)
mss(x, name, make.unique = FALSE, ...)
msr(x, name, make.unique = FALSE, ...)
mts(x, name, make.unique = FALSE, ...)
mtr(x, name, make.unique = FALSE, ...)

Arguments

x an object of class 'mefa'.
fun a function to determine what to return, see details. It has no default, because the choice is not trivial.
name optional character vector, names to return if not all possible elements are needed, see details.
make.unique logical, useful to use make.unique = TRUE if names to returne are non-unique, dee details.
... other arguments passed to the generic function as.data.frame.

Details

Four kinds of data frames can be returned, depending on the function used as the fun argument: mss returns summary statistics for samples (richness and abundence) and x$samp; msr returns raw data (x$xtab) and x$samp; mts returns summary statistics for taxa (occurrence and abundence) and x$taxa; mtr returns raw data (t(x$xtab)) and x$taxa.

The name can be used if only a subset of the summary statistics, or raw data should be returned. The character vector should contain names of elements to return (see examples).

It might (rarely) occur, that names of the summary statistics, or the raw data and the column names of the sample/taxa table overlap (contains names that are common in the two set). In this case, the make.unique = TRUE can be used to resolve non-uniqueness and avoid the error message produced otherwise.

The functions supplied as the fun argument can be used separately. Although the usage of the as.data.frame method is more transparent.

Value

A data frame.

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

as.data.frame, mefa

Examples

data(dol.count, dol.samp, dol.taxa)
x <- mefa(stcs(dol.count), dol.samp, dol.taxa)
## These two are equivalent
as.data.frame(x, fun = mss)
mss(x)
## Return only two species
as.data.frame(x, fun = msr, c("iiso", "ppyg"))
## Taxa table and summary
as.data.frame(x, fun = mts)
## Taxa table and raw data transpose
as.data.frame(x, fun = mtr)
## Why is it useful?
## Instead of
glm(x$xtab[,"amin"] ~ microhab + method, data = x$samp, family = poisson)
## it is more convenient to use
glm(amin ~ microhab + method, data = msr(x), family = poisson)

[Package mefa version 3.0-0 Index]