as.xcount {mefa}R Documentation

Makes 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)

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$xcount part will be used, (table$segment is inherited. NA values are not allowed.
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, segment name (default or explicitlydefined) will be overwritten by the inherited table$segment value.
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 results are not of count type but some kind of measurements (eg. biomass, containing decimals) digits can be used to set precision of the data representation, in this case use integers (digits=0 results integers, digits=1 means 1 decimal, etc.).

Value

A result is an 'xcount' object.

Author(s)

Peter Solymos, Solymos.Peter@aotk.szie.hu, http://www.univet.hu/users/psolymos/personal/

See Also

sscount, xcount, mefa, xorder, check.attrib

Examples

### 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

## Not run: 
data(vtable)

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

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

[Package mefa version 1.1-0 Index]