[R] formula parsing, using parts ...

Thomas Lumley tlumley at u.washington.edu
Tue Oct 28 16:08:59 CET 2003


On Tue, 28 Oct 2003, Russell Senior wrote:

> >>>>> "Uwe" == Uwe Ligges <ligges at statistik.uni-dortmund.de> writes:
>
>
> Uwe> See ?formula and its "See Also" Section on how to do formula
> Uwe> manipulation. There's also an example on how to construct a
> Uwe> formula.
>
> Russell> In order to use the 'as.formula(paste(response," ~
> Russell> ",factor))' approach, response and factor seem to need to be
> Russell> strings (at least they seem to if response is "log(x)" or the
> Russell> like).  Whereas, for pairwise.t.test they need to be names.
> Russell> What is the proper way to do that?
>

I'd actually advise a different strategy.  Consider:

data(airquality)
formula<- log(Ozone)~factor(Month)

m<-lm(formula,data=data)
a<-anova(m)

mf<-model.frame(lm)

pairwise.t.test(mf[,1], mf[,2])


	-thomas




More information about the R-help mailing list