[Rd] Retrieving an unevaluated argument

From: hadley wickham <h.wickham_at_gmail.com>
Date: Wed 01 Feb 2006 - 22:01:52 GMT

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

> a1(list(y=x^2))
list(y = x^2)

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

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

> b(list(x^2), a1)


The best I've been able to do is:

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

> b(list(x^2), a2)


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


R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Feb 02 09:08:21 2006

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:40 GMT