【问题标题】:R code to produce a Consort diagram programmatically using DiagrammeR?使用 DiagrammeR 以编程方式生成 Consort 图的 R 代码?
【发布时间】:2021-11-19 02:25:28
【问题描述】:

我想以编程方式创建一个 Consort 图来描述随机试验中患者的流动情况。

有没有人有 R 代码来使用 DiagrammeR 生成这个图表(见下面的链接)?

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

【问题讨论】:

    标签: r graphics graphviz diagrammer


    【解决方案1】:

    5年前在stackoverflow上问过。答案使用包diagramcreating tree diagram for showing case count using R

    Google 发现了一些 graphviz 代码: http://blogs.sas.com/content/graphicallyspeaking/2016/10/20/outside-box-consort-diagram/

    RStudio 可以直接预览 Graphviz .dot 文件:

    https://blog.rstudio.org/2015/05/01/rstudio-v0-99-preview-graphviz-and-diagrammer/

    或者,

    library(DiagrammeR)
    consort <- file("consort.dot")
    grViz(diagram = consort)
    close(consort)
    

    “consort.dot”如下:

    digraph g {
    start [shape = box, label = "CONSORT Graph"];
    node0 [shape = box, label = "All Patients\nN=1000"];
    node1 [shape = box, label = "Full Analysis Set\nN=800"];
    node2 [shape = box, label = "Excluded\nN=100"];
    node3 [shape = box, label = "Not Included\nN=100"];
    node4 [shape = box, label = "Safety Set\nN=700"];
    node5 [shape = box, label = "Not Dosed\nN=100"];
    node6 [shape = box, label = "Treatment A\nN=200"];
    node7 [shape = box, label = "Treatment B\nN=150"];
    node8 [shape = box, label = "Treatment C\nN=200"];
    node9 [shape = box, label = "Treatment D\nN=150"];
    start -> node0 -> node1 -> node4 -> {node6 node7 node8 node9};
    node0 -> node2;
    node0 -> node3;
    node1 -> node5;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 2010-11-23
      • 1970-01-01
      • 2017-12-27
      • 1970-01-01
      • 1970-01-01
      • 2012-10-01
      相关资源
      最近更新 更多