On Thu, May 1, 2014 at 4:08 PM, Kevin Ushey <[email protected]> wrote:
> Henrik,
>
> If I understand correctly, you want something along the lines of
> (following your example):
>
> foo <- function(expr) {
> if (!is.language(expr)) substitute(expr)
> else expr
> }
>
> ## first example
> expr0 <- foo({ x <- 1 })
> expr1 <- foo(expr0)
> stopifnot(identical(expr1, expr0))
>
> ## second
> expr2 <- foo(foo(foo(foo(expr0))))
> stopifnot(identical(expr2, expr0))
Unfortunately this won't work in general because is.language evaluates expr:
foo(stop("Uh oh!"))
In general, I'm with Bill Dunlap - you're better off being explicit
with formulas.
Hadley
--
http://had.co.nz/
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel