Wilke, Claus O
2016-Mar-06 18:34 UTC
[Rd] Could unit.list() from grid package be made an exported function?
Hello, certain manipulations of ggplot2 graphs, in particular aligning them, require the function grid:::unit.list(). See e.g. these posts on stackoverflow: http://stackoverflow.com/questions/34032621/element-replacement-in-grid-unit-vector http://stackoverflow.com/questions/32580946/setting-absolute-size-of-facets-in-ggplot2/32583612#32583612 http://stackoverflow.com/a/35823179/4975218 Since this seems to be a reasonably common issue, would it be possible to export grid:::unit.list(), so it can be used in packages? (Am I sending this to the right audience? It?s not clear to me how to reach the maintainer of the grid package in base R.) Thanks! Claus -- Claus Wilke Professor and Department Chair, Integrative Biology The University of Texas at Austin 2500 Speedway, A4800 Austin, Texas 78712 512 232 2459 [[alternative HTML version deleted]]
Paul Murrell
2016-Mar-07 19:01 UTC
[Rd] Could unit.list() from grid package be made an exported function?
Hi I think the right solution is to add [<- methods for units. I will take a look at whether I can get that done for the release of R 3.3.0 Paul On 07/03/16 07:34, Wilke, Claus O wrote:> Hello, > > certain manipulations of ggplot2 graphs, in particular aligning them, > require the function grid:::unit.list(). See e.g. these posts on > stackoverflow: > http://stackoverflow.com/questions/34032621/element-replacement-in-grid-unit-vector > >http://stackoverflow.com/questions/32580946/setting-absolute-size-of-facets-in-ggplot2/32583612#32583612> http://stackoverflow.com/a/35823179/4975218 > > Since this seems to be a reasonably common issue, would it be > possible to export grid:::unit.list(), so it can be used in > packages? > > (Am I sending this to the right audience? It?s not clear to me how to > reach the maintainer of the grid package in base R.) > > Thanks! > > Claus > > -- Claus Wilke Professor and Department Chair, Integrative Biology > The University of Texas at Austin 2500 Speedway, A4800 Austin, Texas > 78712 512 232 2459 > > > [[alternative HTML version deleted]] > > ______________________________________________ R-devel at r-project.org > mailing list https://stat.ethz.ch/mailman/listinfo/r-devel >-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
Paul Murrell
2016-Mar-07 20:12 UTC
[Rd] Could unit.list() from grid package be made an exported function?
Hi Subassignment for units has been committed to r-devel. You should now be able to do things like ... x <- unit(1:3, "mm") x[2] <- unit(.5, "npc") (see grid/tests/units.R for more complex examples) This works for me for the three stackoverflow scenarios. Any confirmation that it also works for you would be welcome. Paul On 07/03/16 07:34, Wilke, Claus O wrote:> Hello, > > certain manipulations of ggplot2 graphs, in particular aligning them, > require the function grid:::unit.list(). See e.g. these posts on > stackoverflow: > http://stackoverflow.com/questions/34032621/element-replacement-in-grid-unit-vector > >http://stackoverflow.com/questions/32580946/setting-absolute-size-of-facets-in-ggplot2/32583612#32583612> http://stackoverflow.com/a/35823179/4975218 > > Since this seems to be a reasonably common issue, would it be > possible to export grid:::unit.list(), so it can be used in > packages? > > (Am I sending this to the right audience? It?s not clear to me how to > reach the maintainer of the grid package in base R.) > > Thanks! > > Claus > > -- Claus Wilke Professor and Department Chair, Integrative Biology > The University of Texas at Austin 2500 Speedway, A4800 Austin, Texas > 78712 512 232 2459 > > > [[alternative HTML version deleted]] > > ______________________________________________ R-devel at r-project.org > mailing list https://stat.ethz.ch/mailman/listinfo/r-devel >-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
Wilke, Claus O
2016-Mar-08 20:54 UTC
[Rd] Could unit.list() from grid package be made an exported function?
Paul, Subassignment for units has been committed to r-devel. You should now be able to do things like ... x <- unit(1:3, "mm") x[2] <- unit(.5, "npc") (see grid/tests/units.R for more complex examples) Yes, I just tried the latest R devel and it works for me. However: This works for me for the three stackoverflow scenarios. I ran into an additional problem when trying to replicate this example: http://stackoverflow.com/a/32583612/4975218 This line in the function set_panel_size() causes an error for me: g$widths[panel_index_w] <- rep(list(width), nw) Error in `[<-.unit`(`*tmp*`, panel_index_w, value = list(4, 4, 4)) : Value being assigned must be a unit I can avoid the error by changing the line into: g$widths[panel_index_w] <- rep(grid:::unit.list(width), nw) This, however, again uses grid:::unit.list(). Maybe there?s another way around this, but turning a single width value into a unit.list seems the obvious way to go in a case like this. So again, I?d like to request that grid:::unit.list() be made an exported function as well. It seems quite useful any time somebody wants to make a list of units. Thanks! Claus -- Claus Wilke Professor and Department Chair, Integrative Biology The University of Texas at Austin 2500 Speedway, A4800 Austin, Texas 78712 512 232 2459 [[alternative HTML version deleted]]
Maybe Matching Threads
- Could unit.list() from grid package be made an exported function?
- Could unit.list() from grid package be made an exported function?
- Quartz graphic device can be extremely slow in some cases
- Meaning of /, :, and %in% in lmer
- lme4: How to specify nested factors, meaning of : and %in%