R/make.countarray.R

Defines functions make.countarray

Documented in make.countarray

make.countarray <-
function(mdf,traits){
# make.countarray() - do countnotna() on all traitpairs and store counts in matrix returned
  if(is.null(mdf$rel)) {
    df <- mdf
  } else {
    df <- mdf$df
  }

  l <- length(traits)
  counts <- array(0,c(l,l))
  dimnames(counts) <- list(traits,traits)
  for(i in traits){
    counti <- countnotna(df[,i])
    for(j in traits){
      countj <- countnotna(df[,j])
      counts[i,j] <- length(df[,i][!is.na(df[,i]) & !is.na(df[,j])])
    }
  }
  return(counts)
}

Try the dmm package in your browser

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

dmm documentation built on July 26, 2023, 5:23 p.m.