R/mpdn.r

Defines functions mpdn

Documented in mpdn

mpdn<-function(comm, pd, abundance.weighted = TRUE, time.output=FALSE)
{
  if(sum(colnames(comm)!=rownames(pd))>0)
  {
    sp.name=intersect(colnames(comm),rownames(pd))
    comm=comm[,match(sp.name,colnames(comm)),drop=FALSE]
    pd=pd[match(sp.name,rownames(pd)),match(sp.name,rownames(pd)),drop=FALSE]
  }
  comt=comm
  if(!abundance.weighted)
  {
    comt[comt>0]=1
    num=rowSums(comt)
  }
  comt=comt/rowSums(comt)
  comt=as.matrix(comt)
  pd=as.matrix(pd)
  comd=comt %*% pd
  res=comd * comt
  res=rowSums(res)
  if(!abundance.weighted)
  {
    res=res*(num/(num-1))
  }
  res
}

Try the iCAMP package in your browser

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

iCAMP documentation built on June 1, 2022, 9:08 a.m.