R/spcdisc.R

Defines functions spcdisc

Documented in spcdisc

spcdisc <- function(x,sort=FALSE)
{
   shannon <- function(y) {
       y <- as.numeric(y)
       frac <- y/sum(y)
       comp <- sum((-1 * frac * log(frac))[frac>0])
       comp <- 1 - (comp/log(length(y)))
       comp
   }
   tmp <- apply(x,1,shannon)
   if (sort) tmp <- tmp[rev(order(tmp))]
   tmp
}

Try the labdsv package in your browser

Any scripts or data that you put into this service are public.

labdsv documentation built on April 10, 2023, 5:08 p.m.