|
Weight Gain in Rats
Before applying analysis of variance to the data in Table ?? we should try to
summarise the main features of the data by calculating means and standard
deviations and by producing some hopefully informative graphs. The data is
available in the data.frame weightgain. The following R code produces the
required summary statistics
R> data("weightgain", package = "HSAUR")
R> tapply(weightgain$weightgain, list(weightgain$source,
+ weightgain$type), mean)
High Low
Beef 100.0 79.2
Cereal 85.9 83.9
R> tapply(weightgain$weightgain, list(weightgain$source,
+ weightgain$type), sd)
High Low
Beef 15.13642 13.88684
Cereal 15.02184 15.70881
To apply analysis of variance to the data we can use the aov function in R
and then the summary method to give us the usual analysis of variance table.
The model formula specifies a two-way layout with interaction terms, where
the first factor is source, and the second factor is type. |
|