Learn R Programming

ume (version 1.5.2)

calc_simpson_index: Calculate the Simpson Diversity Index

Description

The Simpson diversity index is calculated to measure the probability that two randomly selected individuals (e.g., molecular formulas) belong to the same category. It quantifies the dominance or evenness within a dataset.

The Simpson index is defined as: $$D = \sum (p_i^2)$$ where:

  • \(p_i\) is the relative abundance of the \(i\)-th molecular formula.

The index ranges between 0 and 1:

  • A value near 0 indicates high diversity (even distribution of abundances).

  • A value of 1 indicates no diversity (one molecular formula dominates).

Usage

calc_simpson_index(mf, magnitude)

Value

A single numeric value representing the Simpson diversity index. Returns 0 if magnitude is all zeros.

Arguments

mf

Character vector. A list of unique molecular formulas.

magnitude

Numeric vector. A list of respective abundances (intensities) for each molecular formula. Must be non-negative and have the same length as mf.

Examples

Run this code
calc_simpson_index(
  mf = c("C10H20O5", "C12H18O3", "C18H30O6"),
  magnitude = c(1982375, 2424, 312410)
)

Run the code above in your browser using DataLab