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 <- c("population", "timepoint","endpoint")variable_x[1]而不是"人口",例如:

b[label='variable_x[1]=BARI_POP4_5_PRIMARY_CN.csv']

这是你的想法吗?

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='']
  }

相关内容

  • 没有找到相关文章

最新更新