title: How to save multiple ggplot charts in loop for using grid.arrange
body: <p>I have a for loop that creates a different ggplot for a different set of parameters each time through the loop. Right now I am printing N different charts one at a time. I would like to save them so I can use grid.arrange to put them all on one page. This doesn't work:</p>
  
  <pre><code>p &lt;- vector(length = N)
  for(i in 1:N)
     p[i] &lt;- ggplot( ........
  ...
  ...
  grid.arrange(p[1], p[2], .. p[N], nrow = 4)
  </code></pre>
  
  <p>Is there a way to save the plots for later plotting a grid of plots on a page outside the loop, or is there a way to set up the grid specification before the loop and and produce the gridded plot on the fly as the loop is executed (e.g., the way par is used with plot)?</p>