Difference between revisions of "Diversity index"

From Testiwiki
Jump to: navigation, search
(Answer: something wrong with qD)
m (Answer)
Line 18: Line 18:
  
 
qD <- function(pi, q){
 
qD <- function(pi, q){
print(pi)
 
print(q)
 
print(q)
 
 
pi <- pi/sum(pi)
 
pi <- pi/sum(pi)
 
out <- rep(NA, length(q))
 
out <- rep(NA, length(q))
Line 99: Line 96:
 
return(out)
 
return(out)
 
}
 
}
library(OpasnetBaseUtils)
+
 
data <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
+
cat("Functions loaded.\n")
diversity(amount=data, species = 1:20, transect = c(rep(1, 10), rep(2, 10)), q = c(0, 1, 2))
 
  
 
</rcode>
 
</rcode>
Line 121: Line 117:
 
'''Example 2
 
'''Example 2
  
<rcode include="page:Diversity_index|name:answer|page:OpasnetBaseUtils|name:generic" variables="
+
<rcode include="page:OpasnetBaseUtils|name:generic|page:Diversity_index|name:answer" variables="
name:data|description:Select your data|type:selection|options:'5/54/Tigre-data.csv';Tigre|default:'5/54/Tigre-data.csv'|
+
name:wikidata|description:Select your data|type:selection|options:'5/54/Tigre-data.csv';Tigre|default:'5/54/Tigre-data.csv'|
name:q|description:Which q values you want to calculate.|type:checkbox|options:0;0;1;1;2;2;3;3;999;∞|default:0;1;2;999
+
name:wikiq|description:Which q values you want to calculate.|type:checkbox|options:0;0;1;1;2;2;3;3;999;∞|default:0;1;2;999
 
">
 
">
 
library(OpasnetBaseUtils)
 
library(OpasnetBaseUtils)
 
library(xtable)
 
library(xtable)
data <- opasnet.csv(data, wiki = "opasnet_en", sep = ",")
+
data <- opasnet.csv(wikidata, wiki = "opasnet_en", sep = ",")
 
data <- data[data$Species != 1, ]
 
data <- data[data$Species != 1, ]
  
Line 134: Line 130:
 
transect <- data$Transect
 
transect <- data$Transect
  
out <- diversity(amount, species, transect, q)
+
out <- diversity(amount, species, transect, wikiq)
 
print(xtable(out), type = 'html')
 
print(xtable(out), type = 'html')
  
 +
diversity(amount=1:20, species = 1:20, transect = c(rep(1, 10), rep(2, 10)), q = c(0, 1, 2))
  
 
</rcode>
 
</rcode>

Revision as of 19:29, 8 January 2012



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

+ Show code

Example 1 to use function

Give your data in R format or leave empty for example data:

Is your data individual data or group abundancies?:

+ Show code

Example 2

Select your data:

Which q values you want to calculate.:
0
1
2
3

+ Show code

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>