From ggrothendieck at gmail.com  Fri Jul  7 14:51:47 2006
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Fri, 7 Jul 2006 08:51:47 -0400
Subject: [Rd] Modifying parsed code
In-Reply-To: <f8e6ff050607070508h7fe3807fu739763f80a472be0@mail.gmail.com>
References: <f8e6ff050607070508h7fe3807fu739763f80a472be0@mail.gmail.com>
Message-ID: <971536df0607070551l6cfe54aar19ce3c4c9850b749@mail.gmail.com>

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 at 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Modifying parsed code
Gabor Grothendieck