Re: [Rd] Modifying parsed code

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 07 Jul 2006 - 12:51:47 GMT

Assuming the desired output is a character string try:

> f <- function(x) deparse(substitute(x))
> f(3+y)
[1] "3 + y"

On 7/7/06, hadley wickham <h.wickham@gmail.com> wrote:
> I would like to take this:
>
> .img(plot(1:10), filename="a")
>
> and produce
>
> plot(1:10)
>
> ie. whenever .img is used, I want to take the first argument and throw
> away everything else.
>
> (I am trying to produce a Sweave like environment in which I can apply
> certain functions, but not have them displayed in the output)
>
> I think I should be able to do it using substitute, but I don't know
> how to operate on language objects. Any hints would be appreciated.
>
> Thanks,
>
> Hadley
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Jul 07 23:00:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 07 Jul 2006 - 14:24:45 GMT.

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