R/OCN_to_igraph.R

OCN_to_igraph <- function (OCN, 
                           level) {
  
  if (missing(OCN)) {
    stop("Input OCN cannot be missing")
  }
  if (!(level %in% c("FD","RN","AG"))) {
    stop("Invalid level")
  }
  if (length(OCN$RN$nNodes)==0 && (level %in% c("RN","AG"))){
    stop('Missing aggregation level in OCN. Run landscape_OCN and/or aggregate_OCN prior to OCN_to_SSN.')
  }
  
  sub_OCN <- NULL
  eval(parse(text=(paste("sub_OCN <- OCN$",level,sep=""))))
  
  mm <- as.dgCMatrix.spam(sub_OCN$W)
  g <- graph_from_adjacency_matrix(mm)
  
  invisible(g)
}
  

Try the OCNet package in your browser

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

OCNet documentation built on Nov. 24, 2023, 1:06 a.m.