title: Lay out multiple ggplot graphs on a page
body: <p>I generate a list of ggplot objects inside a loop as follows:</p>
  
  <pre><code>myPlots = list()
  for(i in 1:length(maturities)){
    myPlots[[i]] &lt;- ggplot(deltaIR.df, aes(sample = deltaIR.df[,i])) + 
                    stat_qq() + stat_qq_line() + 
                    labs(title=maturities[i],
                    x = "Theoretical (Normal)", 
                    y = "Empirical Distribution")
  }
  </code></pre>
  
  <p>Depending on the dataset, there could be between 4 and 10 plots in myPlots. I now want to print them on one page in two rows, and have tried various methods with varying degrees of success. The most promising approach is</p>
  
  <pre><code>library(ggpubr)
  grid.arrange(myPlots[[1]], myPlots[[2]], myPlots[[3]], myPlots[[4]], 
               myPlots[[5]], myPlots[[6]], myPlots[[7]], myPlots[[8]], nrow = 2)
  </code></pre>
  
  <p>This clearly works, but requires me to enumerate all the objects, and I don't know how many objects there will be. I tried to simplify this by writing</p>
  
  <pre><code>ggarrange(myPlots, nrow = 2)
  </code></pre>
  
  <p>but received a warning message:</p>
  
  <pre><code>Warning message:
  In as_grob.default(plot) : Cannot convert object of class list into a grob.
  </code></pre>
  
  <p>What am I doing wrong, and how can I fix this? Ideally, a simple, single, line of code will print all the plots stored in myPlots in two rows.</p>
  
  <p>Thanks in advance</p>
  
  <p>Thomas Philips </p>