Skip to content

Instantly share code, notes, and snippets.

@gluc
Created December 17, 2016 16:03
Show Gist options
  • Save gluc/211eadb783b6fc4388a74ea8cd3a2a1f to your computer and use it in GitHub Desktop.
Save gluc/211eadb783b6fc4388a74ea8cd3a2a1f to your computer and use it in GitHub Desktop.
Newest version of DiagrammeR
nodes <- structure(list(id = 1:11, style = c("", "", "", "", "", "", "",
"", "", "", ""), shape = c("", "", "egg", "egg", "", "egg", "egg",
"", "egg", "egg", "egg"), fillcolor = c("", "Thistle", "", "",
"", "", "", "LightBlue", "LightBlue", "LightBlue", "LightBlue"
), fontname = c("", "", "", "", "", "", "", "", "", "", ""),
tooltip = c("- name: Acme Inc.", "This is the accounting department",
"- cost: 1e+06\n- p: 0.5", "- cost: 5e+05\n- p: 0.75", "- name: Research",
"- cost: 2e+06\n- p: 0.25", "- cost: 750000\n- p: 0.9", "- name: IT",
"- cost: 4e+05\n- p: 0.2", "- cost: 250000\n- p: 0.05", "- cost: 50000\n- p: 1"
), fontcolor = c("", "Firebrick", "", "", "", "", "", "",
"", "", ""), penwidth = c("", "", "", "", "", "", "", "5px",
"5px", "5px", "5px"), label = c("Acme Inc.", "Accounting",
"New Software", "New Accounting Standards", "Research", "New Product Line",
"New Labs", "IT", "Outsource", "Go agile", "Switch to R")), .Names = c("id",
"style", "shape", "fillcolor", "fontname", "tooltip", "fontcolor",
"penwidth", "label"), row.names = c(NA, 11L), class = "data.frame")
edges <- structure(list(id = c(1L, 1L, 1L, 2L, 2L, 5L, 5L, 8L, 8L, 8L),
from = c(1L, 1L, 1L, 2L, 2L, 5L, 5L, 8L, 8L, 8L), to = c(2L,
5L, 8L, 3L, 4L, 6L, 7L, 9L, 10L, 11L), arrowhead = c("",
"", "", "", "", "", "", "", "", ""), color = c("", "", "",
"", "", "", "red", "", "", ""), penwidth = c("", "", "",
"", "", "", "3", "", "", ""), label = c("", "", "", "", "",
"", "Focus!", "", "", ""), fontcolor = c("", "", "", "",
"", "", "red", "", "", "")), .Names = c("id", "from", "to",
"arrowhead", "color", "penwidth", "label", "fontcolor"), class = "data.frame", row.names = c(NA,
10L))
theme <- structure(c("rankdir = 'TB'", "style = 'filled,rounded', shape = 'box', fillcolor = 'GreenYellow', fontname = 'helvetica'",
"arrowhead = 'vee', color = 'grey35', penwidth = '2'"), .Names = c("graph",
"node", "edge"))
library(DiagrammeR)
graph <- create_graph(nodes, edges, theme)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment