| calc_shannon_index | R Documentation |
The Shannon diversity index is calculated to quantify the diversity of molecular formulas based on their relative abundances. This index considers both the richness (number of unique formulas) and the evenness (distribution of abundances). Higher values indicate greater diversity.
The Shannon index is defined as:
H = -\sum (p_i \cdot \ln(p_i))
where:
p_i is the relative abundance of the i-th molecular formula.
Zero-abundance formulas are excluded from the calculation.
calc_shannon_index(mf, magnitude)
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 |
A single numeric value representing the Shannon diversity index. Returns 0 if magnitude is all zeros.
calc_shannon_index(
mf = c("C10H20O5", "C12H18O3", "C18H30O6"),
magnitude = c(1982375, 2424, 312410)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.