[R] eval in parent frame: scoping rule confusion

Jonathan Q. Li jonathan_li at agilent.com
Fri Mar 15 02:53:56 CET 2002


Hi all,

Look at the following "stupid" function that is created just to show the
problem:

outlayer <- function(x)
{
	inlayer <- function(z){
		e1 <- parent.frame()
		eval(expression(y<-log(z)),e1)
 	}
	inlayer(10)
y
}

I have a compilation error when running this. My purpose is to create "y"
variable equal to log(z) in
the frame of "outlay". How can I achieve this?

Thanks a lot in advance!

Jonathan

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list