[R] ANOVA in R

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Thu Sep 14 11:05:15 CEST 2006



Try

test <- data.frame(day.1=c(2,3,3,6,1), 
     day.4=c(7,2,4,6,3),
     day.8=c(2,8,7,8,4))

test

test.long <- reshape(test, direction="long", 
	  varying=c("day.1","day.4","day.8"),
	  v.names="response",
	  timevar="day",
	  times=names(test))

test.long$day <- factor(test.long$day)

test.long

aov(response ~ day, data=test.long)


I hope that this helps,

Andrew


On Thu, Sep 14, 2006 at 09:23:13AM +0100, Russell Compton wrote:
> Despite having used R on a daily basis for the past two years, I'm
> encountering some difficulty performing an ANOVA on my data. What I'm trying
> to do is the following:
> 
>  
> 
> Given data such as:
> 
>  
> 
> Day 1    Day 4    Day 8
> 
> 2          7          2
> 
> 3          2          8          
> 
> 3          4          7
> 
> 6          6          8
> 
> 1          3          4
> 
>  
> 
> I want to use ANOVA to determine if there is a significant change over the
> three days. In other stats packages I have used, I can just select this data
> and run the ANOVA function and get the F and p values. However in R, the
> anova function seems to only work with a fitted model, eg. Linear
> regression. This function seems to assume there is a relationship such as
> day1~ day 4 + day 8, but in my case there isn't - I just want to perform an
> ANOVA without regression. If anyone could point me in the right direction
> I'd greatly appreciate it,
> 
>  
> 
> Thanks
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
Email: a.robinson at ms.unimelb.edu.au         http://www.ms.unimelb.edu.au



More information about the R-help mailing list