# Gmisc: lineGrob problem

I am trying to draw a Markov diagram. The code below works fine up to the last (commented out) line.

``````Tp <- boxGrob(glue("State 1:  Tp",
"  ",
"Entered:    72 (IA: 48, IAK: 24)",
"Censored:   8 (IA:   7, IAK:   1)",
"Failed:       11 (IA:   4, IAK:   7)",
"To II:          53 (IA: 37, IAK: 16)",
.sep = "\n"),
txt_gp = gpar(fontsize = 11),
width = .4, height = .4, y = 0.8, x = 0.2)
II <- boxGrob(glue("State 2:  II",
"  ",
"Entered:      53 (IA: 37, IAK: 16)",
"Censored:   30 (IA: 20, IAK: 10)",
"Failed:           0 (IA:   0, IAK:   0)",
"To LostII:     23 (IA: 17, IAK:    6)",
.sep = "\n"),
txt_gp = gpar(fontsize = 11), width = .4, height = .4,
y = 0.8, x = 0.8)
LostII <- boxGrob(glue("State 3:  LostII",
"  ",
"Entered:    23 (IA:  17, IAK:  6)",
"Censored:  18 (IA:  14, IAK:  4)",
"Failed:         5 (IA:   3, IAK:   2)",
"To Failed:     5 (IA:   3, IAK:   2)",
.sep = "\n"),
txt_gp = gpar(fontsize = 11), width = .4, height = .4,
y = 0.2, x = 0.8)
Failed <- boxGrob(glue("State 4:  Failed",
"  ",
"Entered:        16 (IA: 7, IAK: 9)",
"Failed:           16 (IA: 7, IAK: 9)",
.sep = "\n"),
txt_gp = gpar(fontsize = 11), width = .4, height = .4,
y = 0.2, x = 0.2)
Tp; II; LostII; Failed

connectGrob(Tp, II, type = 'horizontal')
connectGrob(II, LostII, type = 'vertical')
connectGrob(LostII, Failed, type = 'horizontal')
connectGrob(Tp, Failed, type = 'vertical')
connectGrob(II, Failed, type = 'vertical')
``````

GraphAppPrintJob.pdf (6.6 KB)

I now need to add an arrow from the lower left corner of the top right box to the upper right corner of the lower left box. The commented out last two lines should do this, but it isn't working. What am I doing wrong? Any alternative way to draw this arrow?
Thanks in advance for any help/suggestions.
Larry Hunsicker

Addendum: It turns out to be easier than I thought. Though "vertical" in the connectGrob() call seems to imply a direct arrow down, it actually means start the arrow from the bottom of the starting box. If the ending box is not directly down, the arrow will slant down from the bottom of the starting box to the top of the ending box. I have amended my example above to show the correction.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.