Learn R Programming

mefa (version 1.1-4)

as.xcount: Make an Object of Class 'xcount' from a Table

Description

The function converts a sample/species crosstable into an 'xcount' object. Count and measurement type data are allowed.

Usage

as.xcount(table, species.columns = TRUE, segment = "unspecified", digits = NULL, n = NULL)

Arguments

table
a data frame or matrix with sample/species count data. It can either be an object of class 'mefa', in this case, only the table$data part will be used, table$segment is inherited. If table is an object of class
species.columns
if FALSE, species are rows and samples are columns. By default it is TRUE.
segment
arbitrary name of the segment (eg. adult, juvenile, male, female) whose data are included in the table, by default it is "unspecified". In case of 'mefa' objects, value of segment will be overwritten by the inherited t
digits
NULL (default) is used when results are count data (eg. number of individuals). If result is not integer, but digits=NULL, error message is given. If result is not of count type but some kind of measurements (eg. biom
n
element of the 'xclist' or 'mflist' object to choose.

Value

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

See Also

sscount, xcount, mefa, xorder, check.attrib

Examples

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

xc <- as.data.frame(rbind(
c(4, 0, 0),
c(2, 4, 0),
c(0, 0, 5),
c(0, 0, 0)
))
rownames(xc) <- c("sample1", "sample2", "sample3", "sample4")
colnames(xc) <- c("species1", "species2", "species3")

(xc1 <- as.xcount(xc))

(xc2 <- as.xcount(xc, segment = "female"))

xc <- xc + 0.2
(xc3 <- as.xcount(xc, digits=0))

(xc4 <- as.xcount(xc, digits=1))

### Example 2: field data of Villany Hills

data(vtable)

v1 <- as.xcount(vtable, species.columns = FALSE)
v1

v2 <- as.xcount(vtable, species.columns = FALSE, segment = "adult")
v2

Run the code above in your browser using DataLab