shannon | R Documentation |
Function shannon
calculates the Shannon index and its variance for a vector of counts.
shannon(x)
x |
a vector of counts |
Hp |
the sample Shannon index |
VHp |
the sample variance of the Shannon index |
Jan Graffelman (jan.graffelman@upc.edu)
#
# Shannon index for allele frequencies of a biallelic MN blood group polymorphism
#
x <- c(MM=298,MN=489,NN=213)
p <- af(x)
shannon(c(p,1-p))$Hp
#
# Shannon index for the allele frequencies of an STR
#
data("NistSTRs")
AlleleTable <- table(c(NistSTRs[,1],NistSTRs[,2]))
AlleleFreq <- AlleleTable/sum(AlleleTable)
shannon(AlleleFreq)$Hp
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.