Skip to content
Prev 19322 / 63424 Next

Retrieving an unevaluated argument

I'm trying to retrieve an unevalated argument (a list in particular). 
I can do this easily when I call the function directly:

a1 <- function(x) match.call()$x
list(y = x^2)

But when the function is called by another function, it gets trickier

b <- function(x, f) f(x)
x

The best I've been able to do is:

a2 <- function(x) parse(text=deparse(substitute(x, parent.frame())))[[1]]
list(x^2)

But I'm sure there must be a better way!

Hadley