I'm trying to create a flow chart using the DiagrammeR
package in R and wish to have the arrows start from and point to the center of each node. I tried to use the headclip
and tailclip
options and they seem to help get the arrows start from and end at the same point. However, for some reason, it starts from the center of the node and oddly overlaps with the nodes. This is the code I've been using and the (incorrect) output diagram:
data <- list(a=1000, b=800, c=600, d=400)
grViz("
digraph flowchart {
graph [layout = dot, rankdir = LR]
# node definitions with substituted label text
node [fontname = Helvetica, shape = rectangle, fixedsize = true, width = 3, height = 0.8]
tab1 [label = '@@1'];
tab2 [label = '@@2'];
tab3 [label = '@@3'];
tab4 [label = '@@4'];
tab5 [label = '@@5'];
node [fontname = Helvetica, shape = rectangle, fixedsize = true, width = 3, height = 0.5]
rank = same; tab6; tab7; tab8; tab9;
tab6 [label = '@@6']
tab7 [label = '@@7']
tab8 [label = '@@8']
tab9 [label = '@@9']
tab10 [label = '@@10']
tab11 [label = '@@11']
# edge definitions with the node IDs
edge[tailclip = false, headclip = false];
tab1 -> tab3 -> {tab6 tab7 tab8 tab9};
tab1 -> tab4;
tab2 -> tab4;
tab2 -> tab5 -> {tab10 tab11};
}
[1]: paste0('Status known at 30 days \\n (n = ', data$a, ')')
[2]: paste0('Status known at 1 year \\n (n = ', data$a, ')')
[3]: paste0('Status known at 30 days \\n but not 1 year \\n (n = ', data$a, ')')
[4]: paste0('Status known for both \\n 30 days and 1 year \\n (n = ', data$a, ')')
[5]: paste0('Status known at 1 year \\n but not 30 days \\n (n = ', data$a, ')')
[6]: paste0('Withdrawal (n = ', data$a, ')')
[7]: paste0('Loss to follow-up (n = ', data$a, ')')
[8]: paste0('Missed visit (n = ', data$a, ')')
[9]: paste0('Visit not yet due (n = ', data$a, ')')
[10]: paste0('Missed 30D visit (n = ', data$b, ')')
[11]: paste0('Lost to follow-up (n = ', data$b, ')')
")
I'm really looking for something like this:
Any help would be very much appreciated!
Edit: by removing the headclip
and tailclip
attributes, I get something like this, which is better, but each arrow has a different "vertex." I'm hoping so that they have the same vertex.