0

I want to wrap a function which takes an expression as its argument.

For example:

f <- function(expr1) {
    substitute(expr1)
}
f({Sys.time()})

The result will be

>f({Sys.time()})
{
    Sys.time()
}

However, if I wrap a function g over f:

g <- function(expr2) {
    f(expr2)
}

Then the result becomes

>g({Sys.time()})
expr2

What should I do to make the wrapped result unchanged?

Thanks.

wush978
  • 3,114
  • 2
  • 19
  • 23
  • Same question but this has a better title: http://stackoverflow.com/questions/17407852/how-to-pass-an-expression-through-a-function-for-the-subset-function-to-evaluate/17407998#17407998 – Tyler Rinker Jul 02 '13 at 03:06

1 Answers1

1

You can use:

g <- function(...) {
    f(...)
}

## > g({Sys.time()})
## {
##     Sys.time()
## }
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519