rdiagrammer

flowchart using digraph in Diagrammer


I'm trying out DiagrammeR to build some flowcharts and I'm interested in knowing whether I can include values from a secondary data frame (data pulled from a SQL database).

I'm using an example from the documentation and I want to add a random value from the Iris dataset.

I wish to add iris[2,4] as a subtext to the ELEPHANT node in my code below, is this possible?

library(DiagrammeR)
grViz("
digraph {

  # graph attributes
  graph [overlap = true]

  # node attributes
  node [shape = box,
        fontname = Helvetica,
        color = blue]

  # edge attributes
  edge [color = gray]

  # node statements
  A; B; C; D; ELEPHANT
  F [color = black]

  # node attributes
  node [shape = circle,
        fixedsize = true,
        width = 0.9]

  # node statements
  1; 2; 3; 4; 5; 6; 7; 8

  # edge statements
  A->1; B->2                   // gray
  B->3 [color = red]           // red
  B->4                         // gray
  C->A [color = green]         // green
  1->D; ELEPHANT->A; 2->4; 1->5; 1->F // gray
  ELEPHANT->6; 4->6; 5->7; 6->7       // gray
  3->8 [color = blue]          // blue
}
")

Solution

  • I believe what I'm looking for is a parameterized diagram which is detailed here https://mikeyharper.uk/flowcharts-in-r-using-diagrammer/