[R] about eval and eval.parent

ronggui 042045003 at fudan.edu.cn
Fri Nov 18 15:57:30 CET 2005


x<-1
f<-function(){
x<-3
eval(substitute(x+y,list(y=10)))
}
f() #13

x<-1
f<-function(){
x<-3
eval(substitute(x+y,list(y=10)), envir = sys.frame(sys.parent()))
}
f() #11

x<-1
f<-function(){
x<-3
eval.parent(substitute(x+y,list(y=10)))
}
f()#11


the help page says:
    "If 'envir' is
     not specified, then 'sys.frame(sys.parent())', the environment
     where the call to 'eval' was made is used. "

     But it seems that the first one is not equal to the second one.
     
Thank you!


 				


2005-11-18

------
Deparment of Sociology
Fudan University

My new mail addres is ronggui.huang at gmail.com
Blog:http://sociology.yculblog.com




More information about the R-help mailing list