I am trying to create a bunch of ggplot2 graphs using the for loop and then saving them on a multi-page pdf document and I am having problems with marrangeGrob. Here is a sample code:
Plots <- list()
Plots[[1]] <- qplot(mtcars$mpg, mtcars$wt)
Plots[[2]] <- qplot(mtcars$cyl, mtcars$wt)
Plots[[3]] <- qplot(mtcars$mpg, mtcars$qsec)
Plots[[4]] <- qplot(mtcars$cyl, mtcars$drat)
library(gridExtra)
MyPlots <- do.call(marrangeGrob, c(Plots, nrow = 1, ncol = 2))
ggsave("My plots on multiple pages.pdf", MyPlots)
I used a similar version of the line do.call(marrangeGrob...in the past, and forced them to work, but now I get this error when trying to execute this line: Error: nrow * ncol >= n is not TRUE. The fact that code like this worked makes me think that since then, something in one of these packages has been updated. Any suggestions to fix this?
source
share