community_diversity: Community Diversity

Description Usage Arguments Value References Examples

View source: R/community_diversity.R

Description

Calculates Shannon's or Inverse Simpson's diversity of a community, but only one measure of diversity can be calculated at a time and must be specified.

Usage

1
2
3
4
5
6
7
community_diversity(
  df,
  time.var = NULL,
  abundance.var,
  replicate.var = NULL,
  metric = c("Shannon", "InverseSimpson")
)

Arguments

df

A data frame containing species and abundance columns and optional columns of time and/or replicate.

time.var

The name of the optional time column

abundance.var

The name of the abundance column

replicate.var

The name of the optional replicate column. If specified, replicate must be unique within the dataset and cannot be nested within treatments or blocks.

metric

The diversity measure to return:

  • "Shannon": The default measure, calculates Shannon's diversity.

  • "InverseSimpson": Calculates inverse of Simpson's diversity.

Value

The community_diversity function returns a data frame with the following attributes:

References

Magurran, A.E. 2004. Measuring Biological Diversity. Blackwell Publishing, Malden MA, USA.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data(pplots)
#Example with both time and replicates
df <- subset(pplots, plot == 25 | plot == 6)
community_diversity(df,
                    time.var="year", 
                    replicate.var = "plot", 
                    abundance.var = "relative_cover") # for Shannon's diversity measure

df <- subset(pplots, plot == 25 | plot == 6)
community_diversity(df, 
                    time.var="year", 
                    replicate.var = "plot", 
                    abundance.var = "relative_cover", 
                    metric = "InverseSimpson") # for Inverse of Simpson's diversity measure

#Example with no replicates
df <- subset(pplots, plot == 25)
community_diversity(df,
                    time.var="year", 
                    abundance.var = "relative_cover") # for Shannon's diversity measure
                    
#Example with no time or replicate
df <- subset(pplots, plot == 25 & year == 2002)
community_diversity(df,
                    abundance.var = "relative_cover") # for Shannon's diversity measure

laurenmh/codyn documentation built on Dec. 5, 2020, 3:41 p.m.