On Thu, 18 Mar 2004, Gabor Grothendieck wrote: > > Tony, Thomas. Thanks for your help. Your comments were very > useful. > > Unfortunately, my next step gives me a new round of problems. > > The following is the same as the last example except that instead > of hard coding the function into the expression I wanted to > pass it to the expression. It seems like one has to do a double > substitute to get this effect but I am having problems getting this > to work. >
The problem is that f is a function, not an expression. You need to work with body(f) Either > f<-function(){a+1}> body(f)<-do.call("substitute",list(body(f),list(a=quote(b))))> f function () { b + 1 } or > f<-function(){a+1} > body(f)<-eval(substitute(substitute(expr,list(a=quote(b))),list(expr=body(f)))) > f function () { b + 1 } -thomas ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html