diagrammeR - 改编自“如何在我的流程图中添加武器?”
Posted
技术标签:
【中文标题】diagrammeR - 改编自“如何在我的流程图中添加武器?”【英文标题】:diagrammeR - adaptation from "how can I add arms to my flowchart?" 【发布时间】:2021-12-17 05:50:35 【问题描述】:我在这里找到了以下图表示例 (diagrammer - how can I add arms to my flowchart?):
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
【问题讨论】:
【参考方案1】:这应该可以让您启动并运行。只需添加更多(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
")
【讨论】:
谢谢布赖恩,完美!你知道有没有办法增加向右箭头的长度? 今天没时间测试,但看起来有一个minlen
参数可能会有所帮助。 rich-iannone.github.io/DiagrammeR/graphviz_and_mermaid.html以上是关于diagrammeR - 改编自“如何在我的流程图中添加武器?”的主要内容,如果未能解决你的问题,请参考以下文章