R/create.N.matrix.R

create.N.matrix <-
function(mat){
  nspp <- nrow(mat)
  Nmat <- matrix(nrow = nspp,ncol = nspp)
  row <- 0
  for (spp in 1:nspp){
    if (spp < nspp){
      for (spp_next in (spp + 1):nspp){
        Nmat[spp,spp_next] <- sum(mat[spp,]*mat[spp_next,])
        Nmat[spp_next,spp] <- sum(mat[spp,]*mat[spp_next,])
      }  
    }
  }  
  return(Nmat)
}

Try the cooccur package in your browser

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

cooccur documentation built on May 2, 2019, 6:44 a.m.