From wilke at austin.utexas.edu  Tue Mar  8 21:54:48 2016
From: wilke at austin.utexas.edu (Wilke, Claus O)
Date: Tue, 8 Mar 2016 20:54:48 +0000
Subject: [Rd] Could unit.list() from grid package be made an exported
 function?
In-Reply-To: <56DDE098.20708@stat.auckland.ac.nz>
References: <DE6ECFF5-1424-4039-833D-BE1C4192A558@austin.utexas.edu>
	<56DDE098.20708@stat.auckland.ac.nz>
Message-ID: <D7E599B9-ADAC-459D-B561-6A268E5A57CF@austin.utexas.edu>

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]]



[Rd] Could unit.list() from grid package be made an exported function?
Wilke, Claus O