r-lib / gtable

The layout packages that powers ggplot2
https://gtable.r-lib.org
Other
87 stars 18 forks source link

Unit comparison still not fixed in r/cbind #46

Open thomasp85 opened 9 years ago

thomasp85 commented 9 years ago

I seem to run into the following error

Error in mmm < each : comparison of these types is not implemente

when trying to bind together two plots generated with ggplot2 e.g.

p1 <- qplot(mpg, cyl, data=mtcars, geom='line')
p2 <- qplot(drat, wt, data=mtcars, geom='point')
rbind(ggplotGrob(p1), ggplotGrob(p2))

The same error was referenced in #15 by baptiste but that PR was closed down. What is the status of this?

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

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] ggplot2_1.0.0 gtable_0.1.2  MSsary_0.0.9  mzR_2.0.0     Rcpp_0.11.3  

loaded via a namespace (and not attached):
 [1] assertthat_0.1      Biobase_2.26.0      BiocGenerics_0.12.1 codetools_0.2-9     colorspace_1.2-4    DBI_0.3.1           digest_0.6.6        dplyr_0.3.0.2      
 [9] gridExtra_0.9.1     labeling_0.3        magrittr_1.5        MASS_7.3-35         munsell_0.4.2       parallel_3.1.2      plyr_1.8.1          proto_0.3-10       
[17] RColorBrewer_1.1-2  reshape2_1.4.1      RSQLite_1.0.0       scales_0.2.4        stringr_0.6.2       tools_3.1.2        
baptiste commented 8 years ago

FWIW in https://github.com/baptiste/gridextra/blob/master/R/gtable.r I redefined a few gtable functions to improve rbind/cbind/join behaviour, though if I remember correctly joins still had some issues, and ggplot2 broke for some reason.

thomasp85 commented 8 years ago

You did, and I've used that as a base for my own hacks when needed. Maybe I'll add a PR when I have the time. An additional nicety would be to have a "first.nonzero" and "last.nonzero" option