Hi D,

R is taking drug as numeric, you ned indicate to R that drug is a factor:

> example12_7$drug <-factor(example12_7$drug)
> ej2<-aov(time~drug,data=example12_7)
> summary(ej2)
            Df Sum Sq Mean Sq F value Pr(>F)  
drug         2  21.98  10.991   4.188 0.0345 *
Residuals   16  41.99   2.624                 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 


Regards, 

Andrés


El 29/11/2012, a las 14:39, David Arnold <dwarnold45@suddenlink.net> escribió:

> Hi, I am encountering a difficulty I don't understand. Be patient, I'm very
> new to analysis of variance.
> 
> If I load this data:
> 
> example12_7=read.table("http://msemac.redwoods.edu/~darnold/math15/data/chapter12/example12_7.dat",header=TRUE)
> 
> The run the oneway.test:
> 
> oneway.test(time~drug,data=example12_7,var.equal=TRUE)
> 
> I get these results:
> 
> data:  time and drug 
> F = 4.1881, num df = 2, denom df = 16, p-value = 0.03445
> 
> Now, I've done the problem by hand and this result agrees with my
> calculations. Now I try aov and get these results:
> 
> res1 <- aov(time~drug,data=example12_7)
> summary(res1)
> 
>            Df Sum Sq Mean Sq F value Pr(>F)
> drug         1   7.96   7.964   2.417  0.138
> Residuals   17  56.01   3.294
> 
> Note these do not agree with above. However, if I enter the data by hand:
> 
> Drug1=c(7.3,8.2,10.1,6.0,9.5)
> Drug2=c(7.1,10.6,11.2,9.0,8.5,10.9,7.8)
> Drug3=c(5.8,6.5,8.8,4.9,7.9,8.5,5.2)
> boxplot(Drug1,Drug2,Drug3)
> 
> Then create a dataframe:
> 
> d=stack(list(Drug1=Drug1,Drug2=Drug2,Drug3=Drug3))
> 
> And run aov again:
> 
> res=aov(values~ind,data=d)
> summary(res)
> 
> I get these results:
> 
>            Df Sum Sq Mean Sq F value Pr(>F)  
> ind          2  21.98  10.991   4.188 0.0345 *
> Residuals   16  41.99   2.624   
> 
> Which completely agree with my calculations. What's going on?
> 
> Thanks.
> 
> D.
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Analysis-of-Variance-tp4651352.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help@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.


	[[alternative HTML version deleted]]


