Dear Thomas, Many thanks for your answer.
On Sat, Jun 30, 2012 at 10:22:52AM +0900, Thomas Lumley wrote:
1) good: If I run the following using "Rscript"
?test1 <- function(e1) {
? e1 <- substitute(e1)
? FuncIt(100, e1)
?}
?f <- test1(rnorm(1))
?print(f)
then I get the following output:
?function ()
?{
? ? for (funcit.i in 1:100) {
? ? ? ? rnorm(1)
? ? }
?}
?<environment: 0x102260c28>
This is what I want. ?But why do I need the extra "substitute"
in test1? ?I only found by experiment that this is needed.
You don't. You need an extra quote() in the argument. [...] You can get around this using substitute(), which extracts the unevaluated code from the formal argument, but it's probably a bad idea, since the user of the function should expect all the arguments to be evaluated.
I want my final function to work like system.time, i.e. the user should not have to type "quote()" all the time when calling the top-level function of my measuring mechanism. Is there a way to do the quoting inside the top-level function call? Many thanks, Jochen Voss