shannon: Shannon index

View source: R/shannon.R

shannonR Documentation

Shannon index

Description

Function shannon calculates the Shannon index and its variance for a vector of counts.

Usage

shannon(x)

Arguments

x

a vector of counts

Value

Hp

the sample Shannon index

VHp

the sample variance of the Shannon index

Author(s)

Jan Graffelman (jan.graffelman@upc.edu)

Examples

#
# 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

HardyWeinberg documentation built on May 29, 2024, 6:17 a.m.