Learn R Programming

mefa (version 1.1-4)

strify: Stratifie (Aggregate) Object of Class 'xcount' or 'mefa'

Description

Stratifies an object of class 'xcount' or 'mefa' according to levels of a factor, or sample/species attribute, respectively.

Usage

strify(xc, strata, which = c("samples", "species"))

Arguments

xc
an object of class 'xcount' or 'mefa' to be stratified.
strata
a vector with length equal to the number of samples/species (according to which argument). For a 'mefa' object strata is a column within the samples/species attribute table (according to which argument).
which
switches between rows ("samples") and columns ("species") to be stratified.

Value

  • A result is an object of class 'xcount' or 'mefa'.

Details

If the original object is of class 'xcount', the result will be also of 'xcount'. If the original object is of class 'mefa', it must have at least one attribute table, that is not NULL. The stratified attribute table will be NULL in the resulting object. If neither attribute tables are NULL, the result will a 'mefa', if both attribute tables are NULL, the result will an 'xcount' object. Stratifying according to a NULL attribute table has no sense, and an error message is given. In this case use function as.xcount.

See Also

as.xcount, check.attrib, mefa, sscount, xcount, xorder

Examples

Run this code
data(landsnail, vhabitat, vsample, vtable)

v1 <- as.xcount(vtable, FALSE, segment="mixed")
spec <- xorder(v1, which="species", landsnail, 2)
sampl <- xorder(v1, which="samples", vsample, 1)
vmf <- mefa(v1, sampl, spec)

v2 <- strify(vmf, strata = "site.descr", which = "samples")
v2 ## output is 'mefa'

v3 <- strify(v2, strata = "familia", which = "species")
v3 ## output is 'xcount'

check.attrib(as.xcount(v2), which="samples", vhabitat, 2)
habi <- xorder(as.xcount(v2), which="samples", vhabitat, 2)
vmf2 <- mefa(as.xcount(v2), habi, spec)
vmf2 ## 'mefa' again with attributes

Run the code above in your browser using DataLab