as.mefa: Conversion Among Various Object Classes

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

These functions coerce into class 'mefa' or 'stcs'; or converts 'mefa' or 'stcs' obects into a 'data.frame', 'matrix', 'array', 'list'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
as.stcs(x, ...)
## Default S3 method:
as.stcs(x, ...)
as.mefa(x, ...)
as.Mefa(x, ...)
as.Xtab(x, ...)
## Default S3 method:
as.mefa(x, samp, taxa, ...)
## S3 method for class 'array'
as.mefa(x, ...)
## S3 method for class 'list'
as.mefa(x, ...)
## S3 method for class 'mefa'
as.matrix(x, ...)
## S3 method for class 'mefa'
as.array(x, ...)
## S3 method for class 'mefa'
as.list(x, ...)
## S3 method for class 'stcs'
as.data.frame(x, ...)
## 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'.

samp

a data frame containing rows for samples, or NULL. See argument xtab.fixed and details for sample matching options.

taxa

a data frame containing rows for taxa, or NULL. See argument xtab.fixed and details for taxa matching options.

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 return are non-unique, see details.

...

other arguments passed to the generic function as.data.frame.

Details

The usage of most of these coercion methods is trivial. Arrays and lists can be coerced into 'mefa' objects as if those were the segm element of it (either nested, or non nested). The reverse is true, when coercing an object of class 'mefa' into list or array, the segm element is used.

Coercing among object classes 'matrix' and 'mefa' is done via using the xtab element.

By as.data.frame.mefa, 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 abundance) and x$samp; msr returns raw data (x$xtab) and x$samp; mts returns summary statistics for taxa (occurrence and abundance) 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

An object of class 'stcs', 'mefa', 'matrix', 'array', 'list' or 'data.frame', depending on the method used.

Author(s)

P\'eter S\'olymos, [email protected]

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/

See Also

mefa, stcs, as.matrix, as.list, as.array, as.data.frame

Examples

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

mefa documentation built on May 31, 2017, 2:50 a.m.