title: ggplot list of plots to one pdf with different page layouts
body: <p>I want to produce a single pdf with many pages of ggplots. Using <code>gridExtra</code>, I can also build a page of plots with a <code>m x n</code> layout (<code>m</code> rows of plots, <code>n</code> columns of plots). </p>
  
  <p>The function <code>ggsave</code> allows me to write a page of plots, even those that are built with <code>gridExtra</code> having the <code>m x n</code> layout.</p>
  
  <p>Using <a href="https://github.com/baptiste/gridextra/wiki/arrangeGrob" rel="nofollow"><code>arrangeGrob</code></a> it is even possible to <code>ggsave</code> many pages to a single pdf, as long as each page has the same <code>m x n</code> layout.</p>
  
  <p>I'm wondering how I can <code>ggsave</code> a list of plots that have different page layouts? For example, I have a list, <code>l</code>, with length 3 representing 3 pages.</p>
  
  <p><code>l[[1]]</code> is a page with a <code>2 x 2</code> layout and has 4 plots</p>
  
  <p><code>l[[2]]</code> is <code>2 x 1</code> with 2 plots</p>
  
  <p><code>l[[3]]</code> is only <code>1 x 1</code></p>
  
  <p>How could I hack <code>ggsave</code> so that I can write the list <code>l</code> into 1 pdf file with 3 pages having different layouts?  The plots should be displayed in landscape, so typically the command would have the form</p>
  
  <pre><code>ggsave("multipage.pdf", do.call(arrangeGrob, myplots[[i]]), width=11, height=8.5)
  </code></pre>