Skip to content
Prev 165996 / 398502 Next

eval using a environment X but resultsin .GlobalEnv

Saptarshi Guha wrote:
If you don't have control of E to make the changes Gabor suggested, then 
I don't think you can do it without iteration.  But you can leave V 
alone as follows:

V2 <- new.env(parent=V)
eval(E, envir=V2)   # Assignments happen in V2

Now iterate over V2 to move things into .GlobalEnv if you want, e.g.

names <- ls(V2, all=TRUE)
for (n in names) assign(n, get(n, envir=V2))

Duncan Murdoch