gpt4 book ai didi

r - DiagrammeR 和 graphviz

转载 作者:行者123 更新时间:2023-12-04 02:01:46 24 4
gpt4 key购买 nike

我正在尝试从以下位置重现流程图:

http://www.consort-statement.org/consort-statement/flow-diagram

使用 R 中的 DiagrammeR 包。下面是我到目前为止的位置,但我无法让“排除”框与空白节点水平对齐。有什么建议吗?

```{r, echo=FALSE, warning=FALSE, results='hide', message=FALSE}

library(pacman)
p_load(DiagrammeR)

grViz("digraph a_nice_graph {
node [fontname = Helvetica, shape = box, width = 4, fillcolor = LightSalmon, style = filled]
assessed [label = 'Assessed for Elibibility (n = )']
randomized [label = 'Randomized (n = )']
allocatedA [label = 'Allocated to intervention A (n = )']
allocatedB [label = 'Allocated to intervention B (n = )']
lostA [label = 'Lost to follow-up (n = )']
lostB [label = 'Lost to follow-up (n = )']
analyzedA [label = 'Analyzed (n = )']
analyzedB [label = 'Analyzed (n = )']
blank[label = '', width = 0.01, height = 0.01]
excluded[label = 'Excluded (n = )']

subgraph cluster_0 {
rankdir = TD
color = white
assessed -> blank [arrowhead = none]
blank -> randomized
}

subgraph cluster_1 {
rankdir = LR
color = white
blank -> excluded
}

randomized -> {allocatedA allocatedB}
allocatedA -> lostA
allocatedB -> lostB
lostA -> analyzedA
lostB -> analyzedB
}")
```

这是到目前为止的结果图:

enter image description here

最佳答案

我没有使用 RMarkdown 但已经检查了浏览器,我相信这也应该在您的设置中“按原样”工作。重点只是将 blankexcluded 放在同一等级。不需要你试过的子图:

digraph a_nice_graph
{
node [fontname = Helvetica, shape = box, width = 4, fillcolor = LightSalmon, style = filled]
assessed [label = 'Assessed for Elibibility (n = )']
randomized [label = 'Randomized (n = )']
allocatedA [label = 'Allocated to intervention A (n = )']
allocatedB [label = 'Allocated to intervention B (n = )']
lostA [label = 'Lost to follow-up (n = )']
lostB [label = 'Lost to follow-up (n = )']
analyzedA [label = 'Analyzed (n = )']
analyzedB [label = 'Analyzed (n = )']
blank[label = '', width = 0.01, height = 0.01]
excluded[label = 'Excluded (n = )']

{ rank = same; blank excluded }

assessed -> blank[ dir = none ];
blank -> excluded[ minlen = 3 ];
blank -> randomized;
randomized -> {allocatedA allocatedB};
allocatedA -> lostA;
allocatedB -> lostB;
lostA -> analyzedA;
lostB -> analyzedB;
}

产量

enter image description here

关于r - DiagrammeR 和 graphviz,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46750364/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com