Skip to content

Instantly share code, notes, and snippets.

@rich-iannone
Last active October 2, 2015 03:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rich-iannone/fa52046b4867fb8c5d07 to your computer and use it in GitHub Desktop.
Save rich-iannone/fa52046b4867fb8c5d07 to your computer and use it in GitHub Desktop.
Fixed nodes (with specified positions) in DiagrammeR
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create and render an empty graph
empty_graph <- create_graph()
render_graph(empty_graph, output = "visNetwork")
# Create a graph with positioned nodes
nodes <-
create_nodes(nodes = c("a", "b", "c"),
label = TRUE,
x = c(0, 120, 240),
y = c(0, 120, 240))
graph <- create_graph(nodes_df = nodes)
render_graph(graph, output = "visNetwork")
# Create a graph with positioned nodes and edges
nodes <-
create_nodes(nodes = c("a", "b", "c"),
label = TRUE,
x = c(0, 120, 240),
y = c(0, 120, 240))
edges <-
create_edges(from = c("a", "b"),
to = c("b", "c"),
rel = c("rel_a", "rel_b"),
width = c(1, 3))
graph <- create_graph(nodes_df = nodes,
edges_df = edges)
render_graph(graph, output = "visNetwork")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment