I recently started using tableGrob and gridextra to combine multiple graphs and tables. I want mt tableGrob to have a footnote and title.
The following link answers this beautifully:
Adding text to the grid.table
But in the above code, the footnote is truncated for too long. Can someone suggest an alternative so that the footnote automatically wraps around the next row when it reaches the end of the table? If he can turn around in the middle of a word that is also beautiful.
test <- data.frame(boo = c(20,1), do = c(2,10), no = c(3,5),co = c('ed','jeff'))
t1 <- tableGrob(test)
tw <- convertWidth(unit(grobWidth(t1),'npc'),
"in", valueOnly = T)
title <- textGrob("Title is long too or is it??",gp=gpar(fontsize=15))
footnote <- textGrob("footnote is pretty longgg but not unusually longgggggggggkjwd jwkldn", x=0, hjust=0,
gp=gpar( fontface="italic"))
padding <- unit(0.5,"line")
t1 <- gtable_add_rows(t1,
heights = grobHeight(title) + padding,
pos = 0)
t1 <- gtable_add_rows(t1,
heights = grobHeight(footnote)+ padding)
t1 <- gtable_add_grob(t1, list(title, footnote),
t=c(1, nrow(t1)), l=c(1,1),
r=ncol(t1))
grid.arrange(t1)

I want this to work when I have a plot and a grid table. Please, help.
I tried using strwrap and set the width to grobWidth, but this did not work for me.