[R] anova

Jason Turner jasont at indigoindustrial.co.nz
Tue Aug 5 00:03:06 CEST 2003

Peter Dalgaard BSA wrote:
> "Anna  H. Pryor" <anna at ptolemy.arc.nasa.gov> writes:
>>I looked at the Introduction to R and am still confused.  Would it be possible 
>>to ask a question in which I have three vectors and I want to perform an 
>>anova on them.  Say A,B, and C.  Is there a standard form that I could use in 
>>lm to get a model that I could use in anova?  Do I need to know more about my 
>>I really appreciate any help in this.
> There are many forms of anova. The type you describe, I presume, is
> data from three separate groups, aka one-way ANOVA. You need to first
> force your data into the parallel-vector layout like this
>   y <- c(A,B,C)
>   group <- factor(rep(1:3,c(7,9,13))) # provided there are 7 elements
>                                       # in A, 9 in B and 13 in C
> and then 
> anova(lm(y~group))
> or, for some more options, consider
> oneway.test(y~group)

Peter, being modest, didn't mention that he's written a very good book 
about R for technical people who aren't statisticians.  At fatbrain:


If you're not a statistician but are required to use some statistical 
methods (such as anova), this is a very helpful book.  Most of R's 
documentation is aimed at statisticians, so this book fills a gap very 


Indigo Industrial Controls Ltd.
jasont at indigoindustrial.co.nz

More information about the R-help mailing list