Is there anyway to get grid.arrange() to act as split.screen ()? I would like to arrange a table to be located directly underneath the legend.
#create histog
First you should Take a look at this Wiki, there are many examples (look at the arrangeGrob one). So using thoses examples, I managed to have this solution
require(gridExtra)
require(ggplot2)
## original graph
my_hist <- ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
## get the legend
tmp <- ggplot_gtable(ggplot_build(my_hist))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
## create inset table
my_table <- tableGrob(head(diamonds)[,1:3],gpar.coretext =gpar(fontsize=8),gpar.coltext=gpar(fontsize=8), gpar.rowtext=gpar(fontsize=8))
### final result
grid.arrange(my_hist + opts(legend.position = "none"), arrangeGrob(legend, my_table), ncol = 2)
