Calculating Diversity Indices and Species Accumulation Curves in R
October 19, 2016
Description: If you calculate ecological diversity values often, vegan is a very helpful package in R to use. In this R-Tip, we’ll go over two useful functions in vegan to calculate diversity indices and species accumulation curves.
This R-Tip is modified from: https://cran.r-project.org/web/packages/vegan/vignettes/diversity-vegan.pdf
We’ll use a dataset that’s built in with the vegan package, called BCI. This dataset includes tree counts in 1-hectare plots in the Barro Colorado islands. Each plot is a row, and each column represents a species.
To calculate species diversity, we’ll use the function diversity(). This function can be used to calculate the Shannon, Simpson, and Fisher diversity indices. The argument “index” is used to specify which index you would like to calculate. The argument “groups” could be used to find diversity in groups other than what is presented in the data (for example, if you had multiple plots in a stand of trees and were looking to find the average diversity per stand, that argument would be helpful). Let’s calculate the Shannon index for our example.
Another useful function in the vegan package is specaccum(), which will calculate a species accumulation curve. There are a variety of arguments for “method” which can be used to specify how you create the curve. For example, you may use “collector” to look at species accumulation in the order listed in the data if you are interested in seeing how the number of species accumulated in the order which you collected your data. Permutations is the argument to set the number of permutations to run to generate the curve. There are additional arguments which can be used to determine your curve, but these are two of the most useful ones.
For the example, let’s plot a species accumulation curve using the random method (adding sites in a random order) for 100 permutations.
These functions are easy to use and can save you time if you are frequently calculating measures of ecological diversity with your data.
Spatial Ecology @ MSU
Click on "Category" below to search for R code compiled by the Zarnetske Spatial & Community Ecology Lab and students in MSU's Spatial Ecology graduate course (FOR870/FW870)