Diversity index: Difference between revisions
Jump to navigation
Jump to search
(→Answer) |
(→Answer) |
||
Line 25: | Line 25: | ||
} | } | ||
out <- data.frame(Name = c(" | out <- data.frame(Name = c("True diversity with q=0", "True diversity with q=1", "True diversity with q=2", "True diversity with q=∞", "Richness", "Shannon index", "Simpson index", "Inverse Simpson index", "Gini-Simpson index", "Berger-Parker index"), | ||
Symbol = c("0D", "1D", "2D", "∞D", "S", "H' or log(1D)", "λ or 1/(2D)", "1/λ or 2D", "1-λ or 1-1/(2D)", "1/(∞D)"), | |||
Symbol = c(" | Value = c(true(pi,0), true(pi,1), true(pi,2), 1/max(pi), length(pi), log(true(pi,1)), 1/true(pi,2), true(pi,2), 1-1/true(pi,2), max(pi))) | ||
Value = c(true(pi,0), true(pi,1), true(pi,2), 1/max(pi), log(true(pi,1)), 1/true(pi,2), true(pi,2), 1-1/true(pi,2), max(pi))) | |||
return(out) | return(out) | ||
} | } | ||
</rcode> | </rcode> | ||
'''Example to use function | '''Example to use function | ||
Line 43: | Line 40: | ||
library(xtable) | library(xtable) | ||
if(is.null(data)) {data <- c(1,4,6,9,3,4,5,6,5,4,3,3,5,5,7,5,5,4,3,4,5,6,8,9,5,4,5,4,3,3,4,9,6,6,4,5,3,2,1,1,2,3,4,3,2,3,4,5,6,7,7)} | if(is.null(data)) {data <- c(1,4,6,9,3,4,5,6,5,4,3,3,5,5,7,5,5,4,3,4,5,6,8,9,5,4,5,4,3,3,4,9,6,6,4,5,3,2,1,1,2,3,4,3,2,3,4,5,6,7,7)} | ||
data | |||
out <- diversity(data, individual = individual) | out <- diversity(data, individual = individual) | ||
print(xtable(out), type = 'html') | print(xtable(out), type = 'html') |
Revision as of 22:41, 5 January 2012
Moderator:Jouni (see all) |
This page is a stub. You may improve it into a full page. |
Upload data
|
Question
How to calculate diversity indices?
Answer
Upload your data to Opasnet Base. Use the function diversity to calculate the most common indices.
Actual function diversity
Example to use function
The data should be given in R format as a list of values in parenthesis, beginning with c:
c(3,5,3,5,2,1,3,3,4,2) or equivalently c(0.1,0.2,0.4,0.1,0.2)
where the values are either
- identifiers of the species 1,2,3... in which the individuals belong (one entry per individual), or
- abundancies of species, i.e. proportions of individuals belonging to each species among the whole population (one entry per species).
Rationale
Diversity indices are thoroughly described in Wikipedia.
See also
References
Related files
<mfanonymousfilelist></mfanonymousfilelist>