is it possible to bind a heatmap derived from a data.frame and a forest plot derived from another data.frame (using ggplot2) in the same .pdf file so that the forest plot will be on the right side of the heatmap?
I can't give a complete answer without a reproducible example. However, one nice way to do it when you're using the
ggplot2 package is with
First, define your plots without printing them:
heatmap <- ggplot(... forestplot <- ggplot(...
Next, define viewports.
require(grid) vp1 <- viewport(x=0.25, y=0.5, width=0.5, height=0.5) vp2 <- viewport(x=0.75, y=0.5, width=0.5, height=0.5)
y represent the position of the center of the plot, along the x- and y-axes (from the left and bottom, respectively).
Then, use the
pdf("my_file.pdf") print(heatmap, vp=vp1) print(forestplot, vp=vp2) dev.off
Another possibility is to use
grid.arrange, which will come up with a nice arrangement for you automatically:
require(gridExtra) pdf("myfile.pdf") grid.arrange(heatmap, forestplot) dev.off()