I asked a similar question a while ago, and Ananda Mahto generously provided time and code to help make a github package that can combine several graphs of different sizes. I use it a little in my workflow, but I do not plan to translate it into CRAN, but you can download it using the devtools package. Please note that for this you need to install ghostscript in your path too :
## Getting the github overhead stream package:
library(devtools) install_github("plotflow", "trinker") library(plotflow)
## 2 Examples of using the package to combine multiple PDFs
## Example 1 merge_pdf(3, file = "foo.pdf", widths = c(7, 7, 10), heights = c(6, 10, 7)) plot(1:10) plot(1:10, pch=19) plot(1:10, col="red", pch=19) ## Example 2 library(ggplot2) p <- ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot() merge_pdf(2, file = "bar.pdf", widths = c(7, 10), heights = c(6, 10)) plot(1:10) print(p)
Note , if you already have PDF files, you can look at the plotflow: mergePDF function .
source share