Re: [Rd] Version of substitute that evaluates it's first argument

From: William Dunlap <wdunlap_at_tibco.com>
Date: Fri, 27 Jul 2012 22:18:57 +0000

For what it's worth, S+'s substitute() has had an evaluate=FALSE argument to substitute() for quite a while (I think it came with Sv4). evaluate=TRUE means to evaluate its first arument:
  > myCall <- call("myFunc", as.name("arg1"))   > substitute(myCall, list(arg1=as.name("newArg1")), evaluate=TRUE)   myFunc(newArg1)
  > substitute(myCall, list(arg1=as.name("newArg1")))   myCall
It seems like a good name for the option and it is handy.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> -----Original Message-----
> From: r-devel-bounces_at_r-project.org [mailto:r-devel-bounces_at_r-project.org] On Behalf
> Of Hadley Wickham
> Sent: Friday, July 27, 2012 2:53 PM
> To: r-devel_at_r-project.org
> Subject: [Rd] Version of substitute that evaluates it's first argument
>
> Hi all,
>
> Does there already exist a version of substitute that evaluates it's
> first argument? (i.e. it accepts an already quoted expression). This
> seems like something that's pretty handy, but I haven't found any
> existing function to do it:
>
> substitute_e <- function(expr, env) {
> eval(substitute(substitute(expr, env), list(expr = expr)))
> }
>
> f <- quote(x + y + z)
>
> substitute(f, list(y = 1, z = as.name("b")))
> substitute_e(f, list(y = 1, z = as.name("b")))
>
> Hadley
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 27 Jul 2012 - 22:38:40 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 Jul 2012 - 14:20:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive