library(DiagrammeR) # install.packages("DiagrammeR") # https://rich-iannone.github.io/DiagrammeR/graphs.html # https://rich-iannone.github.io/DiagrammeR/graphviz_and_mermaid.html # https://cyberhelp.sesync.org/blog/visualization-with-diagrammeR.html # shttps://graphviz.org/doc/info/shapes.html p=.27 d = read.table(text= paste("P Q\n", p, " ", 1-p), header=T) d x = paste0('labelll') grViz(" digraph SEM { graph [layout = neato, overlap = true, outputorder = edgesfirst] node [shape = rectangle] St [pos='1, 1!', shape=point] A [pos='3, 2!', label='Urn A', color='limegreen', style=filled] C1 [pos='5, 2.2!', label='1 Red', color='limegreen', style=filled] D1 [pos='5, 1.5!', label='other outcome', color='limegreen', style=filled] B [pos='3, 0!', label='Urn B', color='limegreen', style=filled] C2 [pos='5, 0.2!', label='1 Red', color='limegreen', style=filled] D2 [pos='5, -0.5!', label=@@2, color='limegreen', style=filled] St->A [label = '@@1-1'] St->B [label = '@@1-2'] A->C1 [label = '@@1-1'] A->D1 [label = '@@1-1'] B->C2 [label = '@@1-1'] B->D2 [label = '@@1-1'] } [1]: d [2]: x ") grViz(" digraph boxes_and_circles { # a 'graph' statement graph [overlap = true, fontsize = 10] # several 'node' statements node [shape = box, fontname = Helvetica width=1.1 x=10] A; B; C; D; E; # several 'edge' statements A->B A->C B->D B->E } ") grViz(" digraph SEM { graph [layout = neato, overlap = true, outputorder = edgesfirst] node [shape = rectangle] a [pos = '-4,1!', label = 'e1', shape = circle] b [pos = '-3,1!', label = 'ind_1'] c [pos = '-3,0!', label = 'ind_2'] d [pos = '-3,-1!', label = 'ind_3'] e [pos = '-1,0!', label = 'latent a', shape = ellipse] f [pos = '1,0!', label = 'latent b', shape = ellipse] g [pos = '1,1!', label = 'e6', shape = circle] h [pos = '3,1!', label = 'ind_4'] i [pos = '3,-1!', label = 'ind_5'] j [pos = '4,1!', label = 'e4', shape = circle] k [pos = '4,-1!', label = 'e5', shape = circle] a->b e->b [label = '0.6'] e->c [label = '0.6'] e->d [label = '0.6'] e->f [label = '0.321', headport = 'w'] g->f [tailport = 's', headport = 'n'] d->c [dir = both] f->h [label = '0.6', tailport = 'ne', headport = 'w'] f->i [label = '0.6'] j->h k->i } ")