divtable-class: Table holding diversity data

Description Details Examples

Description

An object of class divtable, a diversity table, holds site (rows) by membership (columns) count data expressed using numeric values. Such data could represent (for example) numbers of individuals observed of specific species, numbers of seeds observed originating from different parental trees, or, as a component of class allele_divtables, counts of alleles observed for a specific genetic locus. This is the basic data object of the dispersalDiversity package, and is accepted by the function diversity, which generates descriptive statistics, and the functions alphaDiversityTest, gammaContrastTest and many others that test for differences in the structure of diversity.

Details

A divtable can be assembled by hand, but more typically data will be read into a matrix or data.frame or assembled into a table or xtabs and then converted to a divtable using as.divtable. All functions in the dispersalDiversity package that accept divtable also have a default method that will convert matrix, data.frame, table and xtabs to divtable using as.divtable.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Generate divtables, starting with random site-species pairs with a
## log-normal distribution of abundances
set.seed(42)
t <- data.frame(site = sample(n.sites, n.samples, replace = TRUE),
                source = round(rlnorm(n.samples, .1, 1) + 0.5))
head(t)
## Using table
as.divtable(table(t))

## Using xtabs
as.divtable(xtabs(~ site + species, data = t))

## More complicated, create 'matrix' intermediary
as.divtable(do.call(rbind, lapply(split(t, t$site),
                                  function(x) table(x$source))))

douglasgscofield/dispersalDiversity documentation built on March 30, 2021, 9:50 a.m.