[R] sys.frame() and variables from parent frame

José Miguel Delgado jmigueldelgado at gmail.com
Tue Feb 26 11:40:56 CET 2013


Dear R-help,

I wrote the following lines in order to use a variable from a parent 
frame in my callM() function. I would like to solve this by only editing 
the callM(function). When I run this code I obtain a empty list, meaning 
that eval(ls(),sys.frame(-1)) could not access the variables in the 
parent function. Any suggestions? Thanks in advance!

metaCall <- function()
   {
     NN <- 99
     callM()
     }

callM <- function()
   {
     Ls <- eval(ls(),sys.frame(-1))
     print(Ls)
     ### use Ls to call a certain model named M
     }

metaCall()




-- 
   Zé Miguel
   _______________________________

   JM Delgado
   Reichenberger Str. 52
   10999 Berlim
   Alemanha

   t(d):+49 30 841 18 127
   m(d):+49 176 9633 92 56
   m(p):+351 91 671 07 08



More information about the R-help mailing list