Learn R Programming

mefa (version 1.0-4)

as.xcount: 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 allo
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 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 results are not of count type but some kind of measurements (eg. bi

Value

  • A result is an 'xcount' object.

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