shannon_index: Calculate Shannon Index for diversity

View source: R/shannon_index.R

shannon_indexR Documentation

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_{i=1}^S (p_i * ln(p_i))

where p_i is the relative abundance of each species (i) of the total number of species (S).

Usage

shannon_index(var_tibble)

Arguments

var_tibble

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

Value

double of the Shannon Index

References

\insertRef

shannon1948SoilManageR

\insertRef

spellerberg2003tributeSoilManageR

See Also

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

Examples

#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...


SoilManageR documentation built on June 8, 2025, 9:36 p.m.