[R] What the difference between .Golbalenv and package:base?
John McKown
john.archie.mckown at gmail.com
Mon Aug 25 20:22:39 CEST 2014
On Mon, Aug 25, 2014 at 1:08 PM, PO SU <rhelpmaillist at 163.com> wrote:
>
> Tks for all your details, after your introduction, i really read the ?attach carefully, and i now understand the argument "pos" now, but in my opnion, the details in the function "attach" may do the as.environment(pos) for me.
> And i also understand that, "attach" will copy the attached envir,and add the copied envir into the search path list as you showed the examples to me.
> After all, i want to ask a last question:
> I notice that,
>
>> environmentName(.GlobalEnv)
> [1] "R_GlobalEnv"
>> as.environment(".GlobalEnv")
> <environment: R_GlobalEnv>
>
>>as.environment("R_GlobalEnv")
> Error in as.environment("R_GlobalEnv") :
> no item called "R_GlobalEnv" on the search list
>> .GlobalEnv
> <environment: R_GlobalEnv>
>
>> environmentName("package:stats")
> [1] ""
>> as.environment("package:stats")
> <environment: package:stats>
> attr(,"name")
> [1] "package:stats"
> attr(,"path")
> [1] "C:/Program Files/R/R-3.1.1/library/stats"
>
>
> I am really confused now, while as.environment("package:stats") can be work by convert the name of the environment stats, the environmentName returns "" !
> And get the .GlobalEnv from ".GlobalEnv" ,but can't form "R_GlobalEnv" which is actually the name of the environment.
>
You are now much deeper into the internals of R than my knowledge.
Perhaps one of the truly wise ones here knows. Or this may be a better
question for the people on r-devel. It is really getting more towards
the "why" of R rather than the "how to".
--
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan
Maranatha! <><
John McKown
More information about the R-help
mailing list