I noticed the new environmentName in R 2.5.0dev. Thus I gather that each environment has: (1) a name (2) a hex value so 1. environmentName gets the name. Is there any way to set the name? 2. is there any way to get the hex value for an environment other than doing: e <- new.env() capture.output(e)
On 1/7/2007 5:01 AM, Gabor Grothendieck wrote:> I noticed the new environmentName in R 2.5.0dev. Thus I gather that > each environment has: > > (1) a name > (2) a hex value > > so > > 1. environmentName gets the name. Is there any way to set the name?The NEWS entry says: o New function environmentName() to give the print name of environments such as "namespace:base". This is now used by str(). Take a look at the implementation in src/main/builtin.c. The name isn't part of the environment, this is just derived from how the environment is being used. If you want to attach a label to an environment, use an attribute. You can put an S3 class on an environment if you want it to print your label by default rather than use the standard print mechanism.> 2. is there any way to get the hex value for an environment other than doing: > e <- new.env() > capture.output(e)Not in R code, but there's no use for it in R code, either. If you want to test for whether two variables refer to the same environment, then attach a unique label to the environments when you create them and check the labels. Duncan Murdoch
On Sun, 7 Jan 2007, Duncan Murdoch wrote: [...]> If you want > to test for whether two variables refer to the same environment, then > attach a unique label to the environments when you create them and check > the labels.You can simply use identical(env1, env2). -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595