[R] anova

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Dec 28 08:31:52 CET 2000


Cobalt wrote:
> 
> ..Hello,
> 
> ..I'm learning R and Business Statistics at the same time.
> ..I'm pretty new to R.
> ..I'm trying to perform ANOVA.
> 
> ..I have 3 samples from 3 populations for anova.
> ..So, I decided to perform anova by doing the following:
> 
>         a <- (85,75,82,76,71,85)
>         b <- (71,75,73,74,69,82)
>         c <- (59,64,62,69,75,67)

1. You'll need c() to make this work.
2. That's not a nice solution, because "c" is already the name of a very
basic function (that one you have to use here).

What you mean is, e.g.:

   a1 <- c(85, 75, 82, 76, 71, 85)
         ^
   a2 <- c(71, 75, 73, 74, 69, 82) 
         ^
   a3 <- c(59, 64, 62, 69, 75, 67)
   ^^    ^


> ..Then,
> 
>         print.anova(a,b,c)

Stop! From the help:

1. "Usage: anova(object, ...)" 
2. "Arguments:  *object*  an object containing the results returned by a
model fitting function (e.g. lm or glm). "


> ..I got:
> 
> "Error in print.anova(a, b, c) : anova object must have colnames(.)!"
> 
> ..Then,
>         I tried to create colnames, but probably I didn't understand how to do it properly...And I guess my 'approach' to performing ANOVA in R was definitely wrong too.....
> 
> ..Please, help me with ANOVA. I suspect, it's not that difficult...but still can't figure out how to do it.
> ..Thanks in advance.

So a *sample* session:

   a1 <- c(85, 75, 82, 76, 71, 85)
   a2 <- c(71, 75, 73, 74, 69, 82) 
   a3 <- c(59, 64, 62, 69, 75, 67)
   my.obj <- lm(a1 ~ a2 + a3)
   anova(my.obj)


Hope this helps.

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list