3

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

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

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

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

这是迄今为止的结果图:

在此处输入图像描述

4

1 回答 1

4

我没有使用 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;
}

产量

在此处输入图像描述

于 2017-10-21T07:33:30.373 回答