Diversity index: Difference between revisions
Jump to navigation
Jump to search
(first draft based on en:Diversity index) |
(example code works) |
||
Line 26: | Line 26: | ||
out <- data.frame(Name = c("Richness", "Shannon index", "Simpson index", "Inverse Simpson index", | out <- data.frame(Name = c("Richness", "Shannon index", "Simpson index", "Inverse Simpson index", | ||
"Gini-Simpson index", "Berger-Parker index"), | "Gini-Simpson index", "Berger-Parker index"), | ||
Symbol = c("0D | Symbol = c("S or 0D", "H' or log(1D)", "λ or 1/(2D)", "1/λ or 2D", "1-λ or 1-1/(2D)", "∞D"), | ||
Value = c(true(pi,0), log(true(pi,1)), 1/true(pi,2), true(pi,2), 1-1/true(pi,2), max(pi))) | Value = c(true(pi,0), log(true(pi,1)), 1/true(pi,2), true(pi,2), 1-1/true(pi,2), max(pi))) | ||
return(out) | return(out) | ||
} | } | ||
</rcode> | </rcode> | ||
{{attack|# |With the example data, H' shows 0 which is not plausible. What's wrong?|--[[User:Jouni|Jouni]] 01:10, 5 January 2012 (EET)}} | |||
'''Example to use function | '''Example to use function | ||
<rcode> | <rcode include="page:Diversity_index|name:answer" variables=" | ||
name:data|description:Give your data in R format c(4,2,4,6,1,2,3,8,9) or leave empty for example data| | |||
name:individual|description:Is your data individual data or group abundancies?|type:selection|options:TRUE;Individual;FALSE;Group|default:TRUE | |||
"> | |||
library(xtable) | library(xtable) | ||
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)} | ||
out <- diversity(data, individual = | out <- diversity(data, individual = individual) | ||
print(xtable(out), type = 'html') | print(xtable(out), type = 'html') | ||
</rcode> | </rcode> |
Revision as of 23:10, 4 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
⇤--#: . With the example data, H' shows 0 which is not plausible. What's wrong? --Jouni 01:10, 5 January 2012 (EET) (type: truth; paradigms: science: attack)
Example to use function
Rationale
Diversity indices are thoroughly described in Wikipedia.
See also
References
Related files
<mfanonymousfilelist></mfanonymousfilelist>