I am using gridExtra to display multiple plots and I found that somehow ggplot objects are not saved properly. Take a look at this simple code:
Working version:
gs <- list()
for(i in 1:4){
gs[[i]] <- qplot(rnorm(100), geom = "histogram", main = i)
}
grid.arrange(grobs = gs, ncol = 2)
Problem version:
gs <- list()
for(i in 1:4){
x <- rnorm(100)
gs[[i]] <- qplot(x, geom = "histogram", main = i)
}
grid.arrange(grobs = gs, ncol = 2)
The second version produces identical plots in my R workspace. The version I am using is ggplot2-v2.2.1 and gridExtra-v2.3