I have a data frame whose first colum contains the names of the variables 
and whose second colum contains the values to assign to them:

   : kkk <- data.frame(vars=c("var1", "var2", "var3"), 
                     vals=c(10, 20, 30), stringsAsFactors=F)

If I do 

   : assign(kkk$vars[1], kkk$vals[1])

it works

   : var1
   [1] 10

However, if I try with mapply this is what I get:

   : mapply(assign, kkk$vars, kkk$vals)
   var1 var2 var3 
     10   20   30 
   : var2
   Error: object 'var2' not found

Maybe I have not undestand how mapply and assign work. Do you have
any comments?

Thanks,

  -Sergio.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to