I have used do.call("substitute", ...) to work around the fact that substitute does not evaluate its first argument:
R> z <- quote(func(arg)) R> do.call("substitute", list(z, list(func=quote(myFunction), arg=as.name("myArgument")))) myFunction(myArgument) S+'s substitute (following S version 4) has a third argument, evaluate, which controls whether the first argument is evaluated or not: S+> z <- quote(func(arg)) S+> substitute(z, list(func=quote(myFunction), arg=as.name("myArgument")), evaluate=TRUE) myFunction(myArgument) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Saptarshi Guha > Sent: Wednesday, September 07, 2011 2:21 PM > To: R-help@r-project.org > Subject: [R] Using substitute on a function parameter > > Hello, > > I would like to write a function where substitute operates on the > parameter, but ... > > > > Expression = function(o,l) substitute(o, l) > > Expression({x=.(FOO)}, list(FOO=2)) > o > > How do i get substitute to work on the contents of o. > > Regards > Saptarshi > > ______________________________________________ > 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. ______________________________________________ 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.