I am building a Markov diagram using Gmisc::boxGrob. The text in each of the boxes is essentially a minitable, and it is very hard to get the columns to align using the default variable spacing font. The boxGrob() help specifies that one can specify a font for the text in a gpar(fontfamily = 'fontname') parameter in the boxGrob() function. But I have been unable to get the code to accept specification of a monospaced font using the fontfamily variable. Does anyone have a way to set the fontfamily to a monospaced font?
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')
Thanks in advance to anyone that can help me with this.
Larry Hunsicker