[R] Set environment name

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jul 14 13:53:09 CEST 2010


On Tue, 13 Jul 2010, thmsfuller066 at gmail.com wrote:

> Hello All,
>
> ?environmentName shows how to get the environment name. But I don't
> see how to set the name in the first place. Could you tell me where to
> look for the function that set the environment name?

It is not AFAIK possible from R code.  environmentName() will give the 
name which has been assigned at C level, but names(), which would 
otherwise work, is disabled for non-vector objects.

The underlying reason is the unusual copying semantics of 
environments -- it makes little sense to allow the name to be changed.

I do wonder why you would want this: if there is a good reason then we 
could perhaps allow new.env() to set the name.  But I added 
environmentName() to be able programatically to identify system 
environments such as packages and namespaces, especially the latter.

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



More information about the R-help mailing list