Learn R Programming

mefa (version 1.1-4)

check.attrib: Check Consistency of 'xcount' Object and Attribute Table

Description

This function checks consistency of an object of class 'xcount' and an attribute table (data frame) by comparing row/column names (as sample/species identifiers) and values in an index column of the data frame.

Usage

check.attrib(xc, which = c("samples", "species"), attrib, index = 0)

Arguments

xc
an object of class 'xcount'.
which
switch for rows ("samples") or columns ("species") of the 'xcount' object to be compared according to index.
attrib
data frame to be checked. NA values are counted.
index
column identifier within attrib to be compared according to row/column names (as sample/species identifiers) of the 'xcount' object according to value of which. By default, index = 0, and rownames are take

Value

  • callreturns the call.
  • set.relation"equal" means the two sets (row/column names of the 'xcount' object and elements in the index column) are equal, "inclusion" means the two sets are inclusive and no missing elements found, "intersect" means the two sets intersect (required elements are listed in missing), "separate" means the two sets have no common elements (required elements are listed in missing).
  • duplicatea list of duplicate elements or NULL.
  • missinga list of missing elements or NULL.
  • naindicates the number of NA values found in attrib.

See Also

mefa, 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))

check.attrib(xct, "samples", sampletab, 1)
check.attrib(xct, "species", spectab, 1)
check.attrib(xct, "species", spectab, 2)
check.attrib(xct, "species", spectab[2:5,], 1)
check.attrib(xct, "species", spectab[4:5,], 1)

### Example 2: field data of Villany Hills

data(vtable, vsample, landsnail)

vt <- as.xcount(vtable, FALSE)

check.attrib(vt, which="species", landsnail, 2)
check.attrib(vt, which="samples", vsample, 1)

Run the code above in your browser using DataLab