R/visNetwork.R

Defines functions createVisNetwork

Documented in createVisNetwork

#' createVisNetwork
#'
#' @param nodes Nodes.
#' @param edges Edges.
#' @param background Background color.
#' @param border Border color.
#' @param highlight Highlight color.
#' @author Jayachandra N
#' @description
#' Generates network map using the nodes and edges objects generated by
#' getNodes and getEdges functions respectively.
#' @return Network map visualization
#' @import dplyr
#' @import visNetwork
#' @export
#' @examples
#' nodes <- getNodes(head(mtcars), c("cyl", "gear", "vs"), group = TRUE)
#' res <- fixNodeBias(head(mtcars))
#' edges <- getEdges(getAssociation(res), getNodes(res, group = TRUE))
#' createVisNetwork(nodes, edges)
createVisNetwork <- function(nodes, edges, background = "lightblue",
                             border = "darkblue", highlight = "yellow") {
  visNetwork::visNetwork(nodes, edges) %>%
    visNetwork::visNodes(color = list(background = "lightblue",
                                      border = "darkblue",
                                      highlight = "yellow"),
                         shadow = list(enabled = TRUE, size = 10))
}

Try the netknitr package in your browser

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

netknitr documentation built on April 3, 2025, 5:47 p.m.