[R] as.environment() does not work for "package:base"?

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Mar 30 22:27:58 CEST 2004


NULL is the correct answer: as an environment base is denoted by NULL.
Did you think to try

ls(envir=NULL)

?  If not, do so now.

On Tue, 30 Mar 2004, Philippe Grosjean wrote:

> Hello,
> 
> I want to retrieve one environment from the search path. I have:
> 
> > search()
>  [1] ".GlobalEnv"      "package:R2HTML"  "package:tcltk"   "package:methods"
> "package:ctest"
>  [6] "package:mva"     "package:modreg"  "package:nls"     "package:ts"
> "Autoloads"
> [11] "package:base"
> > as.environment(1)
> <environment: R_GlobalEnv>
> > as.environment(2)
> <environment: package:R2HTML>
> attr(,"name")
> [1] "package:R2HTML"
> attr(,"path")
> [1] "C:/PROGRA~1/R/rw1081/library/R2HTML"
> > as.environment(10)
> <environment: 01749504>
> attr(,"name")
> [1] "Autoloads"
> > as.environment(11)
> NULL
> > as.environment("package:base")
> NULL
> 
> So, everything works fine, except for "package:base", the 11th entry. Is it
> by purpose that as.environment() returns NULL? Is it because "package:base"
> is "sealed"? Then, how do I get the environment corresponding to
> "package:base"?
> 
> Thanks,
> 
> Philippe Grosjean
> 
> .......................................................<°}))><....
>  ) ) ) ) )
> ( ( ( ( (   Prof. Philippe Grosjean
> \  ___   )
>  \/ECO\ (   Numerical Ecology of Aquatic Systems
>  /\___/  )  Mons-Hainaut University, Pentagone
> / ___  /(   8, Av. du Champ de Mars, 7000 Mons, Belgium
>  /NUM\/  )
>  \___/\ (   phone: + 32.65.37.34.97, fax: + 32.65.37.33.12
>        \ )  email: Philippe.Grosjean at umh.ac.be
>  ) ) ) ) )  SciViews project coordinator (http://www.sciviews.org)
> ( ( ( ( (
> ...................................................................
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

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