[R] formula parsing, using parts ...

Spencer Graves spencer.graves at pdf.com
Tue Oct 28 16:44:19 CET 2003


      I got errors from Prof. Lumley's code, but the following 
modification produced for me something that seemed to fit his description: 

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

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

mf<-model.frame(m)

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

      hope this helps.  spencer graves

Thomas Lumley wrote:

>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
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>  
>




More information about the R-help mailing list