Stumbled upon this library as I was reading/browsing around and thought I would do a couple of the examples. Pretty neat.
library(DiagrammeR)
## Warning: replacing previous import by 'htmlwidgets::JS' when loading
## 'DiagrammeR'
# import way
#grViz("boxes.dot")
# or we could do this here
nodes <- "
digraph boxes_and_circles {
#a 'graph' statement
graph [overlap = true, fontsize = 10]
# several 'node' statements
node [shape = box,
fontname = Helvetica]
A; B; C; D; E; F
node [shape = circle,
fixedsize = true,
width = 0.9]
1; 2; 3; 4; 5; 6; 7; 8
# several 'edge' statements
A->1 B->2 B->3 B->4 C->A
1->D E->A 2->4 1->5 1->F
E->6 4->6 5->7 6->7 3->8
}
"
grViz(nodes)
graph <- "
graph neato {
graph [rankdir = LR]
node [shape = circle,
style = filled,
color = grey,
label = '']
node [fillcolor = red]
a
node [fillcolor = green]
b d c
node[fillcolor = orange]
e f g h i j
k l m n o p
q r s t u v
edge [ color = grey]
a -- {b c d}
b -- {e f g h i j}
c -- {k l m n o p}
d -- {q r s t u v}
e -- {f g h i j}
f -- {q r s t u v}
g -- {e f h i j}
i -- {e t u}
n -- {e f g h i j}
p -- {r s t u v}
q -- {r s t u v}
}
"
grViz(graph)