Learn R Programming

DiagrammeR (version 0.8.1)

visnetwork: Render graph with visNetwork

Description

Render a graph object with the visNetwork R package.

Usage

visnetwork(graph)

Arguments

graph
a dgr_graph object, created using the create_graph function.

Examples

Run this code
# Create a node data frame
nodes <-
  create_nodes(nodes = c("a", "b", "c", "d", "e", "f"),
               label = TRUE,
               fillcolor = c("lightgrey", "red", "orange", "pink",
                         "aqua", "yellow"),
               shape = "circle",
               value = c(2, 1, 0.5, 1, 1.8, 1),
               type = c("1", "1", "1", "2", "2", "2"),
               x = c(1, 2, 3, 4, 5, 6),
               y = c(-2, -1, 0, 6, 4, 1))

# Create an edge data frame
edges <-
  create_edges(from = c("a", "b", "c", "d", "f", "e"),
               to = c("d", "c", "a", "c", "a", "d"),
               color = c("green", "green", "grey", "grey",
                         "blue", "blue"),
               rel = "leading_to")

# Create a graph object
graph <- create_graph(nodes_df = nodes,
                      edges_df = edges)

visnetwork(graph)

Run the code above in your browser using DataLab