Refs:
library(DiagrammeR)
Some complex eg to show several types of tools:
grViz("
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] // sets as circles
2; 3; 4; 5; 6; 7
node [shape = oval,
fixedsize = true,
peripheries = 2,
width = 0.9,
fontname = 'Courier New',
style=filled,
fillcolor = red]
8
node [label =<<table border='0' cellborder='1' cellpadding='3' bgcolor='white'>
<tr><td bgcolor='black' align='center' colspan='2'><font color='white'>header</font> </td></tr>
<tr><td align='left' port='r2'>(2) ¼ •</td>
<td bgcolor='grey' align='right'>$</td>
</tr>
</table>>
] // sets as circles
1
# 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 [label='x ∈ 3']
4->6 [label='β₂=0.85']
5->7 [penwidth = 5]
6->7 [style=dotted,label='dotted']
3->8 [headport = 'e', tailport = 'e', color=blue]
}
")
The greek letters (Cf. here:
Α Β Γ Δ Ε Ζ Η Θ Ι Κ
Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ
Χ Ψ Ω α β γ δ ε ζ η
θ ι κ λ μ ν ξ ο π ρ ς
σ τ υ φ χ ψ ω &thetasym ϒ ϖ
Superscripts and Subscripts are the block U+2070 to U+209F
More symbols: http://csbruce.com/software/utf-8.html. To translate, eg, u+2208
is ∈
.
This is a eg for a probabilistic graphical model description:
grViz("
digraph dot {
graph [compound = true, nodesep = .5, ranksep = .25,
color = crimson, label='Polynomial Regression Model'
/*, rankdir='LR', style=filled, fillcolor = blue*/
]
subgraph cluster1 {
node [shape = diamond,
color = black]
xi
node [shape = circle,
style = filled,
fillcolor = grey]
ti
edge [color = black]
xi -> ti
label='N'
}
node [shape = circle]
w
node [shape = diamond,
color = black,
label = 'α']
alpha
node [shape = diamond,
color = black,
label = 'σ²']
sigma
edge [color = black]
alpha -> w
w -> ti
sigma -> ti
}
",
engine = "dot")
where diamonds describe deterministic parameters; shaded circles describe observed values; and boxes describe multiple variables (in this case \(x_1 \ldots x_n\) and \(t_1 \ldots t_n\)).