From ggrothendieck at gmail.com  Thu Apr 21 13:30:11 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Thu Apr 21 13:30:26 2005
Subject: [Rd] Suggestions for manipulating formula objects
In-Reply-To: <Pine.A41.4.61b.0504201644290.71116@homer07.u.washington.edu>
References: <33078.136.177.22.105.1114027536.squirrel@webmail.fpcc.net>
	<Pine.A41.4.61b.0504201644290.71116@homer07.u.washington.edu>
Message-ID: <971536df05042104304c8622c4@mail.gmail.com>

On 4/20/05, Thomas Lumley <tlumley@u.washington.edu> wrote:
> On Wed, 20 Apr 2005 rlee@fpcc.net wrote:
> 
> > I'm trying to manipulate/change a formula prior to passing it to another
> > function.  A simplified example:
> >
> > User passes formula to my function: y~x
> > My function does: lm(transform(y)~x)
> >
> > Here, transform() is added to the model's response.
> >
> > What is the best way to accomplish this?
> 
> One way is
> 
> formula[[2]]<-substitute(transform(y),list(y=formula[[2]]))
> 

Another way is to use update, e.g.

> fo <- y ~ x
> update(fo, transform(.) ~ .)
transform(y) ~ x


[Rd] Suggestions for manipulating formula objects
Gabor Grothendieck