Learn R Programming

mefa (version 1.1-4)

mefa: Makes Object of Class 'mefa'

Description

Makes and object of class 'mefa' from an 'xcount' and sample and species attribute 'xorder' objects. Incomplete 'mefa' object can becreated, when one out of samples or species attributes are missing.

Usage

mefa(xc, xorder.samples, xorder.species, n = 1)

## S3 method for class 'mefa':
print(x, cutoff = 25, \dots)

## S3 method for class 'mefa':
plot(x, sample.var = NULL, species.var = NULL, \dots)

## S3 method for class 'mefa':
as(x, n = NULL, \dots)

report(x, ...)
## S3 method for class 'mefa':
report(x, filename, n = 1, ordering = "species", biotic.data = 1, 
    species.name = 1, species.order = 1, author = 0, 
    tex = FALSE, binary = FALSE, sep = c(", ", " (", ")", "; "), ...)

Arguments

xc
object of class 'xcount' or 'xclist'. If xc is an object of class 'xclist', than the n argument is used to choose from the list.
xorder.samples
object of class 'xorder' for sample attributes, or NULL.
xorder.species
object of class 'xorder' for species attributes, or NULL.
x
an object of class 'mefa' of 'mflist' (for as.mefa). If mf is an object of class 'mflist', than the n argument is used to choose from the list. For the report method, the object mf can not h
n
element of the 'xclist' or 'mflist' object to choose.
cutoff
number of samples/species with zero toal count to be listed.
sample.var
column index (numeric or character) of the sample attribute table to plot as independent variable.
species.var
column index (numeric or character) of the species attribute table to plot as independent variable.
filename
name of the file to be created in the working directory.
ordering
type of ordering (sectioning), by "species" (default) or by "samples".
biotic.data
list of columns in the sample attribute table of the 'mefa' object, data will be sorted according to subsequent columns (there is no limit for length).
species.name
a column identifier in the species attribute table of the 'mefa' object containing species names.
species.order
a column identifier in the species attribute table of the 'mefa' object, by which the ordering of species names can be made (eg. according to taxonomy).
author
a column identifier in the species attribute table of the 'mefa' object, containing author names for species. By default it is 0, that is no author names are listed.
tex
logical operator, if TRUE species names will be italicized and sectioning will be used according to ordering argument. Default is FALSE.
binary
logical operator, if TRUE count data will not be written into the output file. Default is FALSE, when count data are written.
sep
a character vector, with four elements, containing separator strings. The first is placed between biotic.data values, second is placed before, third is after the count value, fourth is the separator between full data entries. After the l
...
other arguments.

Value

  • A result is an object of class 'mefa'.
  • datacount data from the 'xcount' object.
  • sample.attrdata frame containing data of 'xorder' object containing sample attributes.
  • species.attrdata frame containing data of 'xorder' object containing species attributes.
  • callreturns the call.
  • segmentsegment of the 'xcount' object.
  • digitsdigits of the 'xcount' object.
  • nsamplesnumber of rows (samples) in data.
  • nspeciesnumber of columns (species) in data.
  • totalcountsum of count or measurement in data.
  • presencessum of presences in data.
  • nindsa vector, containing number of individuals (or sum of measurement values) within samples.
  • srichna vector, containing number of species (based on occurrences) within samples.
  • specabunda vector, containing number of individuals (or sum of measurement values) within species.
  • specoccura vector, containing number of occurrences within species.
  • attributescharacter, indicating the presence of "both" or only one ("samples.only" or "species.only") attribute tables.
  • attrib.matrixa matrix with 2 rows and 3 columns. Columns contain values of check.setrel, number of variables and na from 'xorder' objects for samples (first row) and species (second row). If one 'xorder' object is missing, respective row contains NAs.
  • The report method writes text file named filename into the working directory.

Details

The plot method works as for 'xcount' objects if only a 'mefa' object is specified. If sample and species attributes (one or both) are also specified, scatterplots or box-and-whiskers diagrams are drawn, based on the type of the independent variable. Species richness, number of individuals, abundance and number of species occurrences are plotted as response variable. If the crosstable is binary, only richness and occurrences are used.

When tex = TRUE, the result of the report method can be directly used in a LaTeX document by copy-pasting the output or by the include option.

See Also

check.attrib, marmat, sscount, xcount, xorder

Examples

Run this code
### Example 1: simple atrificial data

ss <- data.frame(
cbind(
c("sample1","sample1","sample2","sample2","sample3","sample4"),
c("species1","species1","species1","species2","species3","zero.count"),
c("male","female","male","female","male","male")
),
c(1, 2, 10, 3, 4, 1)
)
colnames(ss) <- c("sample.id", "species.id", "gender", "catch")

spectab <- as.data.frame(rbind(
	c("species3", "family1", "1"),
	c("species2", "family2", "5"),
	c("species1", "family1", "2"),
	c("species5", "family2", "1"),
	c("species4", "family1", "10")
))
colnames(spectab) <- c("species", "taxonomy", "size")

sampletab <- as.data.frame(rbind(
	c("sample3", "bad"),
	c("sample1", "good"),
	c("sample2", "good"),
	c("sample4", "bad")))
colnames(sampletab) <- c("sample", "quality")

xct <- xcount(sscount(ss, zc="zero.count"))
xo1 <- xorder(xct, "samples", sampletab, 1)
xo2 <- xorder(xct, "species", spectab, 1)

mf1 <- mefa (xct, xo1, xo2)
mf1

mf2 <- mefa(xcount(sscount(ss, zc="zero.count"), 2), xo1, xo2)
mf2

### Example 2: field data of Villany Hills

data(landsnail, vsample, vtable)

vt <- as.xcount(vtable, FALSE)
spec <- xorder(vt, which="species", landsnail, 2)
sampl <- xorder(vt, which="samples", vsample, 1)

vmf <- mefa(vt, sampl, spec)
vmf

plot(vmf)
plot(vmf,type="rank")
plot(vmf, 3)
plot(vmf, NULL, 5)
plot(vmf, "site.descr", "shell.dimension")

### Example 3: field data of the dolina

data(dol.count, dol.sample, landsnail)

dmf <- mefa(
dxc <- xcount(sscount(fill.count(dol.count), zc="zero.count")),
xorder(dxc, which="samples", dol.sample, 1),
xorder(dxc, which="species", landsnail, 2)
)

dmf

plot(dmf, "microhabitat", "shell.dimension")

### Reporting
v2 <- strify(vmf, strata = "site.descr", which = "samples")
habi <- xorder(as.xcount(v2), which="samples", vhabitat, 2)
vmf2 <- mefa(as.xcount(v2), habi, spec)

report.mefa("vspec-report.txt", vmf2, "species", c(3,2,4:7), "spec.name", "order", 0,
    FALSE, FALSE, sep = c(", "," (",")","; "))

report.mefa("vsampl-report.txt", vmf2,"samples", c(3,2,4:7), "spec.name", "order", 0,
    FALSE, FALSE, sep = c(", "," (",")",",\n"))

report.mefa("vspec-report.tex", vmf2,"species", c(3,2,4:7), "spec.name", "order", "author",
    TRUE, FALSE, sep = c(", "," (",")","; "))

report.mefa("vsampl-report.tex", vmf2,"samples", c(3,2,4:7), "spec.name", "order", "author",
    TRUE, TRUE, sep = c(", "," (",")",",\n"))

### Sweave example

mefadocs("SampleReport")

Run the code above in your browser using DataLab