[R] Disentagling formulas

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Mon Oct 1 17:34:13 CEST 2007


maybe I didn't understand the problem, but you can do sth like

formula<-y~X1+X2+X3
lm(update.formula(formula,f(Y)~.))

maybe
?all.vars
or
?terms
will help you too.

hth.


Rebecca Sela schrieb:
> I am writing a program in which I would like to take in a formula, change the response (Y) variable into something else, and then pass the formula, with the new Y variable to another function.  That is, I am starting with 
>          formula <- Y~X1+X2+X3
> and I'd like to do something like
>          Y <- formula$Y
>          newY <- f(Y)
>          lm(newY~X1+X2+X3)
> So far, it seems that my only option will be a very complicated sequence of steps involving match.call().  Is there a simpler way to change the response variable in a formula?
>
> Thanks in advance!
>
> Rebecca
>
> --
> Rebecca Sela
> Statistics Department
> Stern School of Business
> New York University
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790



More information about the R-help mailing list