0

I have the following working flowchart created with DiagrammeR package.

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

I was wondering how it is possible to insert into this syntax the variable_x[1] of variable_x <- c("population", "timepoint","endpoint") instead of "population" like:

b[label='variable_x[1]=BARI_POP4_5_PRIMARY_CN.csv']
firmo23
  • 7,490
  • 2
  • 38
  • 114
  • Could you elaborate more? Are you looking to select population given variable_x? – NelsonGon Jan 17 '19 at 07:38
  • Yes I edited in order to make it clear. Instead of "population" inserted manually I want to call it as the 1st component of the variable_x – firmo23 Jan 17 '19 at 12:46
  • You'll need non canonical syntax which uses dplyr like language. I find it more cumbersome. It's available here: https://github.com/rich-iannone/DiagrammeR – NelsonGon Jan 17 '19 at 12:48

1 Answers1

0

Is this what you had in mind?

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])
)

Output:

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='']
  }
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197