5

以下代码使用 DiagrammeR 包在 R 中创建流程图。如何在连接形状的流线中添加“是”或“否”(或任何其他文本)?创建图表时,我的节点通常是决策,我想将流线答案标记为是/否。

library(DiagrammeR)

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
      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
      }
      ")

捕获.png

4

1 回答 1

6

尝试为每个流线定义标签,如下所示:

library(DiagrammeR)

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
      1; 2; 3; 4; 5; 6; 7; 8

      # several 'edge' statements
      A->1 [label='YES']
      B->2 [label='NO'] 
      B->3 [label='...'] 
      B->4 C->A
      1->D E->A 2->4 1->5 1->F
      E->6 4->6 5->7 6->7 3->8
      }
")

希望能帮助到你!:)

于 2018-05-11T13:48:31.393 回答