[Rd] Suggestions for manipulating formula objects
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Apr 21 13:30:11 CEST 2005
On 4/20/05, Thomas Lumley <tlumley at u.washington.edu> wrote:
> On Wed, 20 Apr 2005 rlee at 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
More information about the R-devel
mailing list