title: cbind on ggplotGrob objects fails with "Error in mmm < each : comparison of these types is not implemented"
body: <p>This appears to be similar to an issue that @baptiste was trying to work around back in 2014. I am revisiting code I wrote back in June that involved creating three ggplotGrobs and combining them with a call to cbind. Now, this code fails with the message: "Error in mmm &lt; each : comparison of these types is not implemented." </p>
  
  <p>I thought that this would be specific to my particular application, but I was able to make a very simple, reproducible example. Even if the cbind is performed on two identical ggplotGrobs, this code still fails.</p>
  
  <pre><code>library(ggplot2)
  library(gtable)
  
  # Make some plots
  pl1 &lt;- ggplot(mtcars, aes(x = disp, y = mpg)) +
      geom_point()
  pl2 &lt;- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, colour = Species)) +
      geom_point()
  
  # Convert to grobs
  pl1_grob &lt;- ggplotGrob(pl1)
  pl2_grob &lt;- ggplotGrob(pl2)
  
  # Bind them together -- Error!
  combined_grob &lt;- cbind(pl1_grob, pl2_grob)
  </code></pre>
  
  <p>The error and relevant traceback are here:</p>
  
  <pre><code>&gt; combined_grob &lt;- cbind(pl1_grob, pl2_grob)
  Error in mmm &lt; each : comparison of these types is not implemented
  &gt; traceback()
  8: comp(x_val, y_val)
  7: unit(comp(x_val, y_val), x_unit)
  6: compare_unit(x$heights, y$heights, pmax)
  5: cbind_gtable(x, y, size = size)
  4: f(init, x[[i]])
  3: Reduce(function(x, y) cbind_gtable(x, y, size = size), gtables)
  2: cbind(deparse.level, ...)
  1: cbind(pl1_grob, pl2_grob)
  </code></pre>
  
  <p>This code fails with R-3.4.2 on OS X 10.11.6 with grid_3.4.2, gtable_0.2.0, and ggplot2_2.2.1, AND with R-3.3.2 on Linux (compiled from source on Ubuntu 16.04) with grid_3.3.2, gtable_0.2.0, and ggplot2_2.2.1.</p>
  
  <p>Before making the example above, I noticed that one of the vignettes in the "lemon" package ("gtable_show_lemonade") fails near the very end with the same error upon a cbind of two gtables. I confirmed this error by running the code for this vignette from source, which goes something like:</p>
  
  <pre><code>library(lemon)
  edit(vignette('gtable_show_lemonade', package = 'lemon'))
  # Then use whichever editor you opened to copy the temporary filename
  # of the vignette source, and run this with source()
  </code></pre>
  
  <p>The compiled vignette (with failed cbind) is here: <a href="https://cran.r-project.org/web/packages/lemon/vignettes/gtable_show_lemonade.html" rel="nofollow noreferrer">https://cran.r-project.org/web/packages/lemon/vignettes/gtable_show_lemonade.html</a></p>
  
  <p>The failure during vignette compilation was obtained using the aforementioned R-3.4.2 instance running on OS X 10.11 (El Capitan).</p>
  
  <p>I would appreciate any help with working around this! Since I would like to use my Mac to generate the figures (better font situation), I'm hoping there is a way I can overload a function to fix this.</p>
  
  <p>UPDATE:</p>
  
  <p>This is "only" a problem if <code>size = 'max'</code>, which is the default, is specified (or <code>size = 'min'</code>). I think that I can work around it using <code>size = 'first'</code> or <code>size = 'last'</code>, which do not perform the offending height comparisons, but it is certainly not convenient that the default behavior doesn't work (and there are certain situations <code>size = 'max'</code> is useful).</p>