[R] What the difference between .Golbalenv and package:base?
macqueen1 at llnl.gov
Mon Aug 25 20:51:54 CEST 2014
.GlobalEnv stores objects you create
package:base contains functions and objects provided by R itself
You don¹t need to use .GlobalEnv$a to use the variable named a. Just
is ³a² by itself.
a <- 4
b <- 2*a
Not necessary to use
Similarly, to find an object in the base package, just type its name.
I don¹t know what you are trying to do, or why you think you have to use
But in more than 20 years of using R for many different tasks, I have
never had to do that.
Furthermore, if you are new to R (which I would guess is the case), it
seems unlikely to me that you need to work with environments or use
attach() or assign(). In the vast majority of cases there are simpler ways
that are easier to understand.
You are aware, I hope, that
all return the same result?
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
On 8/24/14, 11:07 PM, "PO SU" <rhelpmaillist at 163.com> wrote:
> As we know, there are a lot of environments in the search() path,
>such as .Golbalenv and package:base .
>And i can just use .Golbalenv$a ,.Golbalenv$b to use the virable, but
>i must use as.envrionment("package:base") to find virable, i feel it not
>For example, when i use the following codes to add a new env into the
> I must always convert the name to the environment, How can i just use
>the following form:
>> assign("a",2,envir=new_name) #like using .GlobalEnv
>mail: desolator88 at 163.com
>Majored in Statistics from SJTU
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help