title: using ggsave and arrangeGrob after updating gridExtra to 2.0.0
body: <p>since I read a lot similar question on stackoverflow so far, I couldn't find a good solution without updating ggplot2 to the development version.</p>
  
  <p>My problem, I have several scripts which use <code>arrangeGrob</code> to create combined graph out of individual graphs. I save them into a variable and <code>print</code> this variable and/or save it with <code>ggsave</code>. Since a lot of my colleagues update there packages regularly (which is a good thing I think), I always get mails my script no longer work after updating to <code>gridExtra 2.0.0</code>.</p>
  
  <p>I am not sure how to handle this, since the new <code>ggplot2</code> version where the problem is solved is still under development. I found an <a href="https://stackoverflow.com/questions/18406991/saving-a-graph-with-ggsave-after-using-ggplot-build-and-ggplot-gtable">article</a> on stack overflow to remove a test if the object to save is a <code>ggplot</code> since the new <code>arrangeGrob</code> function returns a <code>gtable</code> object, but this fails in my case:</p>
  
  <pre><code>library(ggplot2)
  library(grid)
  library(gridExtra)
  a &lt;- data.frame(x=c(1,2,3),
                  y=c(2,3,4))
  p &lt;- ggplot(a, aes(x, y)) + geom_point()
  b &lt;- arrangeGrob(p, p)
  grid.draw(b)
  ggsave('test.pdf', b)
  ggsave &lt;- ggplot2::ggsave
  body(ggsave) &lt;- body(ggplot2::ggsave)[-2]
  ggsave('test.pdf', b)
  </code></pre>
  
  <p>Some output and error on the console:</p>
  
  <pre><code>d&gt; grid.draw(b)
  d&gt; ggsave('test.pdf', b)
  Error in ggsave("test.pdf", b) : plot should be a ggplot2 plot
  d&gt; ggsave &lt;- ggplot2::ggsave
  d&gt; body(ggsave) &lt;- body(ggplot2::ggsave)[-2]
  d&gt; ggsave('test.pdf', b)
  Saving 10.5 x 10.7 in image
  TableGrob (2 x 1) "arrange": 2 grobs
    z     cells    name           grob
  1 1 (1-1,1-1) arrange gtable[layout]
  2 2 (2-2,1-1) arrange gtable[layout]
  d&gt; 
  </code></pre>
  
  <p>The <code>test.pdf</code> is created but it is corrupted in any way and can not be opened. Also the <code>gtable</code> object get printed. So I guess something is wrong here.</p>
  
  <p>But, as you can see, I found in the example code, I found the <code>grid.draw</code> function to plot at least my combined graph but I still can not <code>ggsave</code> it after the modification. </p>
  
  <p>I don't want to use the "old" (<code>pdf(file = "test.pdf");  grid.draw(b); dev.off()</code>) device saving functions as suggested in <a href="https://stackoverflow.com/questions/33134163/saving-plots-using-grid-draw-method-instead-of-gridextra">this article</a>, since they are very uncomfortable to use.</p>
  
  <p>In <a href="https://stackoverflow.com/questions/31458051/store-arrangegrob-to-object-does-not-create-printable-object">this question</a> someone asked exactly how to save the object, but in the answer they just explain to use <code>grid.darw</code> and he accepted the answer as <code>solving the problem</code> and nobody answered on my comments so far.</p>
  
  <p>So I am pretty lost at the moment, how to provide working scripts for those who have and have not updated to new <code>gridExtra</code> package. The way to remove the test within the <code>ggsave</code> function is I guess the best solution since I can check the <code>gridExtra</code> and <code>ggplot2</code> version and just overwrite the <code>ggsave</code> function in case there version do not match, but I could not get it to run.</p>
  
  <p>Looking forward to get some help.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>maybe the <code>sessionInfo</code> helps</p>
  
  <pre><code>d&gt; sessionInfo()
  R version 3.2.0 (2015-04-16)
  Platform: x86_64-apple-darwin13.4.0 (64-bit)
  Running under: OS X 10.9.5 (Mavericks)
  
  locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
  
  attached base packages:
  [1] grid      stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] gridExtra_2.0.0 ggplot2_1.0.1  
  
  loaded via a namespace (and not attached):
   [1] Rcpp_0.12.1      digest_0.6.8     MASS_7.3-44      plyr_1.8.3       gtable_0.1.2    
   [6] magrittr_1.5     scales_0.3.0     stringi_1.0-1    reshape2_1.4.1   devtools_1.9.1  
  [11] proto_0.3-10     tools_3.2.0      stringr_1.0.0    munsell_0.4.2    colorspace_1.2-6
  [16] memoise_0.2.1  
  </code></pre>