baptiste / gridExtra

Miscellaneous Functions for "Grid" Graphics
http://cran.r-project.org/web/packages/gridExtra/index.html
15 stars 4 forks source link

arrangeGrobe w/ hights/widths = c() broken in dev version of R #20

Closed trinker closed 8 years ago

trinker commented 9 years ago

I'm not sure if this is going to be a future problem for folks relying on a behavior maybe they ought not to have been but I noticed that using gridExtra 2.0.0 with grid 3.3.0 the following use of simple c with widths/heights argument results in an error inside arrangeGrob

arrangeGrob(plot1, plot2, widths = c(.4, .6))

This may not be the correct approach but seems to fix it:

arrangeGrob(plot1, plot2, widths = unit(c(.4, .6), "native"))

I'm asking:

  1. Is the first use above no longer going to work?
  2. Is the second approach an equivalent solution?
baptiste commented 9 years ago

it's meant to work (and does for me with current R). Can you show the error message to give a clue? (I don't want to install R-dev so close after a release, it seems less stable.

trinker commented 9 years ago

Yeah works for me with he current build of R as well (under Windows I can run multiple R versions).

library(gridExtra)

grid.arrange(grid::rectGrob(), grid::rectGrob(), heights = c(.3, .7))

## > grid.arrange(grid::rectGrob(), grid::rectGrob(), heights = c(.3, .7))
## Error: is.unit(heights) is not TRUE

sessionInfo()

## R Under development (unstable) (2015-09-19 r69398)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 8.1 x64 (build 9600)
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] gridExtra_2.0.0
## 
## loaded via a namespace (and not attached):
## [1] tools_3.3.0  gtable_0.1.2 grid_3.3.0  

This works though:

grid.arrange(grid::rectGrob(), grid::rectGrob(), heights = grid::unit(c(.3, .7), "native"))

This may be something that goes away when this version of R is released.

baptiste commented 9 years ago

dunno, works for me with R-devel on a Mac. Let's wait and see if this fixes itself, I can't see what could have changed that would cause this error message.