[R] extraction of mean square value from ANOVA

Rolf Turner rolf.turner at xtra.co.nz
Fri May 20 05:16:38 CEST 2011


On 20/05/11 14:51, Cheryl Johnson wrote:
> Thanks for your help. How would I extract each of the 3 values in the 
> vector individually?

If you are going to use R, it would pay you to learn a little bit about it.
Like, e.g., vector indexing.

In your example

     anova(mylm)[["Mean Sq"]][3]

would give the residual mean square.

More perspicuously:

     mnsq <- anova(mylm)[["Mean Sq"]] # A vector of length 3
     MSE <- mnsq[3] # Mean square for error.
     MSB <- mnsq[1] # Mean square for factor b
     MSC <- mnsq[2] # Mean square for factor c

Do read ``An Introduction to R'' as the Posting Guide suggests.

     cheers,

         Rolf Turner



More information about the R-help mailing list