diagramR - 改编自 "how can I add arms to my flowchart?"

diagrammeR - adaptation from "how can I add arms to my flowchart?"

我在这里 () 找到了以下 diagrammeR 示例:

library(DiagrammeR)

grViz("digraph flowchart {
  # node definitions with substituted label text
  node [fontname = Helvetica, shape = rectangle, fixedsize = false, width = 1] 
  1 [label = 'data (100%)']
  2 [label = 'data  (74.4%)']
  3 [label = 'data  (69.6%)']
  4 [label = 'data  (55.4%)']
  m1 [label = 'missing (25.6%)']
  m2 [label = 'missing (4.8%)']

  node [shape=none, width=0, height=0, label='']
  p1 -> 2; p2 -> 3 -> 4;
  {rank=same; p1 -> m1}
  {rank=same; p2 -> m2}

  edge [dir=none]
  1 -> p1; 2 -> p2;
}")

输出为:

就我而言,我在方框 2 和方框 3 之间有多个排除项(m2、m3、m4、m5、m6、m7、m8):

grViz("digraph flowchart {
  # node definitions with substituted label text
  node [fontname = Helvetica, shape = rectangle, fixedsize = false, width = 1] 
  1 [label = 'Box 1']
  2 [label = 'Box 2']
  3 [label = 'Box 3']
  m1 [label = 'm1']
  m2 [label = 'm2']
  m3 [label = 'm3']
  m4 [label = 'm4']
  m5 [label = 'm5']
  m6 [label = 'm6']
  m7 [label = 'm7']
  m8 [label = 'm8']
  
  node [shape=none, width=0, height=0, label='']
  p1 -> 2; p2 -> 3;
  {rank=same; p1 -> m1}
  {rank=same; p2 -> m2}
  {rank=same; p2 -> m3}
  {rank=same; p2 -> m4}
  {rank=same; p2 -> m5}
  {rank=same; p2 -> m6}
  {rank=same; p2 -> m7}
  {rank=same; p2 -> m8}      
  
  edge [dir=none]
  1 -> p1; 2 -> p2;
}")

目前这给了我:

但是我想在方框 2 和方框 3 之间有一个更长的箭头,这样所有 m 个方框一个下面,而不是右边,这可能吗?喜欢:

Box 2
  |--- m2
  |--- m3
  |--- m4
  |--- m5
  |--- m6
  |--- m7
  |--- m8
Box 3

这会让你起床 运行。只需添加更多(p3 -> p4...在边缘部分等)。

library(DiagrammeR)
grViz("digraph flowchart {
  # node definitions with substituted label text
  node [fontname = Helvetica, shape = rectangle, fixedsize = false, width = 1] 
  1 [label = 'Box 1']
  2 [label = 'Box 2']
  3 [label = 'Box 3']

  m1 [label = 'm1']
  m2 [label = 'm2']
  m3 [label = 'm3']
  
  node [shape=none, width=0, height=0, label='']
  p1 -> 2; p3 -> 3
  {rank=same; p1 -> m1}
  {rank=same; p2 -> m2}
  {rank=same; p3 -> m3}
  
  edge [dir=none, arrowhead=none]
  1 -> p1; 2 -> p2; p2 -> p3
}")