Skip to content
Prev 334123 / 398525 Next

Using assign with mapply

On Dec 6, 2013, at 11:27 AM, Julio Sergio Santana wrote:

            
I think you will find that the value returned from the mapply call was a three element list with the desired names and values  ... except you then gave that enclosing list no name and it will be garbage-collected. If you want to have 'assign' do its magic into the global environment, then you need to supply 'mapply' a MoreArgs argument on the other side of the ellipsis:

Usage:
mapply(FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE,
       USE.NAMES = TRUE)

So what happens if you try this:

mapply(assign,  kkk$vars, kkk$vals, MoreArgs = list(envir = .GlobalEnv)