[R] re form data for aov()?
Dan Kelley
kelley.dan at gmail.com
Sun Mar 29 19:47:11 CEST 2009
As a followup, I show below what I get if I "break out" the variables by
making a new data frame with new (boolean) columns that indicate the
treatment. (The experiment was germ count on hands, after cleansing with 4
different methods.)
What I'm hoping is to find a way to do this in a less "hard-wired" way (i.e.
in which I do not have to change my code for every application, explicitly
naming the factors).
> dd<-data.frame(d, Alcohol.Spray=d$Method=="Alcohol.Spray",
> Antibacterial.Soap=d$Method=="Antibacterial.Soap",
> Soap=d$Method=="Soap",Water=d$Method=="Water")
>
> anova(aov(Bacterial.Counts ~ Alcohol.Spray+Antibacterial.Soap+Soap+Water,
> data=dd))
Analysis of Variance Table
Response: Bacterial.Counts
Df Sum Sq Mean Sq F value Pr(>F)
Alcohol.Spray 1 27473 27473 19.4822 0.0001374 ***
Antibacterial.Soap 1 1925 1925 1.3653 0.2524658
Soap 1 484 484 0.3432 0.5626651
Residuals 28 39484 1410
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
--
View this message in context: http://www.nabble.com/reform-data-for-aov%28%29--tp22769850p22770387.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list