Skip to content
Prev 44034 / 398525 Next

Constructing an environment from a data.frame

Duncan Murdoch wrote:

            
I don't think it's easily possibe (but Luke et al. might want to correct 
me). My dirty solution would be:

f4 <- function(df) {
     env <- new.env()
     mapply(function(x, y) assign(y, x, envir=env), df, names(df))
     g <- function()
         eval(quote(x+y), env=env)
     y <- 1:10
     g()
}
f4(df)



Uwe