[R] Problem with aov

Ben Bolker bolker at ufl.edu
Wed Jul 22 23:54:14 CEST 2009




theliver wrote:
> 
> I'm currently doing simple, one way ANOVA using R. 
> 
> I'm analyzing a count based upon an Hour value (0-23) in which it occurs.
> The count varies greatly over the entire day (usually with a range of 400
> or so), but certain hour groupings could be useful for later data
> processing.
> 
> So I've loaded my data:
> data.nas <- read.csv(file="simple.csv",head=TRUE,sep=",")
> [the file has headers of Center, MaxInst(which is the count im
> analyzing),Hour,X.ofCap]
> 
> I've filtered it based on my needs
> data.ztl<-subset(data.nas,Center=="ZTL")
> data.ztlf<-subset(data.ztl,X.ofCap>97)
> 
> which gives me everything I need to start breaking up the hours
> 
> So I enter
> 
> hours15t21.data.ztl<-subset(data.ztlf,Hour>14 & Hour<22)
> 
> then
> 
> aov.15t21.ztl<-aov(MaxInst~Hour, data=hours15t21.data.ztl)
> 
> then
> summary(aov.15t21.ztl)
> 
> and the output is
> 
>                 Df Sum Sq   Mean Sq F value      Pr(>F)  
> Hour          1   2745      2745      4.4879     0.03467 *
> Residuals   461 281939     612                  
> 
> My problem is, since my data set has 7 different Hours, shouldn't the
> first DF be 6?
> 
> I'm not ready to trust this output without knowing why DF is 1 and not 6.
> 
> 

Hour is being treated as a continuous variable, because R has no way of
knowing otherwise.

Try

hours15t21.data.ztl$Hour <- factor(hours15t21.data.ztl)

before running your aov() command.

-- 
View this message in context: http://www.nabble.com/Problem-with-aov-tp24613042p24615055.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list