Learn R Programming

SoilManageR (version 1.0.1)

shannon_index: Calculate Shannon Index for diversity

Description

This function calculates the Index of Shannon (1948) for a tibble with different species.

The formula that is used is $$SI = -\sum_{S=1}^i (p_i * ln(p_i))$$ where \(p_i\) is the relative abundance of each species (\(S\)).

Usage

shannon_index(var_tibble)

Value

double of the Shannon Index

Arguments

var_tibble

a tibble with two columns (name of species, count per species), the second column must be called "count"

References

shannon1948SoilManageR

spellerberg2003tributeSoilManageR

See Also

plant_diversity() to calculate the shannon_index() (and other diversity indices) for a management_df

Examples

Run this code
#create tibble
tibble_example <- tibble::tibble(Plant = c("A","B","C","D","E"), count = c(10,5,8,20,10))

#calculate Shannon Index
shannon_index(tibble_example)  # = 1.505...

Run the code above in your browser using DataLab