Skip to content
Prev 48255 / 63424 Next

Access variable in attached but removed object

On 09/05/2014, 6:54 AM, Rainer M Krug wrote:
Attaching a variable to the search list generally makes a copy of it, so 
it can't be "attached but deleted".  However, "making a copy" of an 
environment just copies the reference to it, so your environment still 
exists on the search list, it just doesn't have a name in the global 
environment.
I don't know why you would have seen character(0) here.  You should have 
seen "test" in the list, because you created it a couple of lines earlier.
You can use assign, or get a reference to the environment using 
as.environment("org:variables"), and access it within that.  For example,

assign("test", 24, pos="org:variables")

or

e <- as.environment("org:variables")
e$test <- 24

Duncan Murdoch