R/joinAdjacency.R

Defines functions joinAdjacency

Documented in joinAdjacency

joinAdjacency <- function(x, vars=c('l_musym', 'r_musym')) {
  
  # extract "left" and "right" map unit symbols, removing missing values
  d <- slot(x, 'data')[, vars]
  edge.list <- as.matrix(na.omit(d))
  
  # init igraph object: note that there will be many duplicate edges
  g <- graph.edgelist(edge.list, directed=FALSE)
  
  # keep track of duplicate edges as weight, then remove
  E(g)$weight <- log(count.multiple(g))
  g <- simplify(g)
  
  # save as weighted adjacancy matrix for plotting with sharpshootR functions
  a <- get.adjacency(g, attr='weight')
  
  return(a)
}

Try the sharpshootR package in your browser

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

sharpshootR documentation built on May 2, 2019, 4:46 p.m.