我们如何在DiagrammeR

时间:2019-01-16 21:11:58

标签: r diagrammer

我使用DiagrammeR软件包创建了以下工作流程图。

library(DiagrammeR)
grViz(
  "digraph{
  graph[layout='dot',outputorder=edgesfirst,overlap=T,rankdir=LR]

  b[label='population=BARI_POP4_5_PRIMARY_CN.csv']
  c [label='timepoint=12']
  d[label='endpoint=ACR50']
  b->c[label='']
  c->d[label='']
  }")

我想知道如何将variable_x[1]的{​​{1}}的{​​{1}}而不是像下面的“人口”插入

variable_x <- c("population", "timepoint","endpoint")

1 个答案:

答案 0 :(得分:0)

这是您的主意吗?

variable_x <- c("population", "timepoint", "endpoint")

cat(sprintf("digraph{
  graph[layout='dot',outputorder=edgesfirst,overlap=T,rankdir=LR]

  b[label='%s=BARI_POP4_5_PRIMARY_CN.csv']
  c [label='timepoint=12']
  d[label='endpoint=ACR50']
  b->c[label='']
  c->d[label='']
  }", variable_x[1])
)

输出:

digraph{
  graph[layout='dot',outputorder=edgesfirst,overlap=T,rankdir=LR]

  b[label='population=BARI_POP4_5_PRIMARY_CN.csv']
  c [label='timepoint=12']
  d[label='endpoint=ACR50']
  b->c[label='']
  c->d[label='']
  }