Skip to content
Prev 343383 / 398506 Next

What the difference between .Golbalenv and package:base?

On Mon, Aug 25, 2014 at 1:07 AM, PO SU <rhelpmaillist at 163.com> wrote:
You might want to try:

new_name <- new.env();
# or if you prefer (such as in a function)
assign("new_name",new.env(),envir=.GlobalEnv);
#
# You may now assign variable into this similar to:
new_name$a <- 2;
gvar <- new_name$a; # get the variable a from environment new_name
gvar <- get("a",envir=new_name); #same thing, but wordy
attach(new_name);
a
gvar <- a;