Skip to content
Prev 78621 / 398506 Next

Two-factor ANOVA Help

On 10/8/05, Jim Brindle <j_brindle at hotmail.com> wrote:
Note that values, as returned from read.table, is already a data frame
and Rater is already a factor so you only need to convert Pipe to a
factor:

values <- read.table("filename.dat", header = TRUE)

# shows classes of columns among other things
# note that Rater is already a factor and values is already a data frame
str(g)

# convert Pipe to a factor
values$Pipe <- factor(values$Pipe)
g <- lm(Volume ~., values)
g
By default R uses treatment contrasts and uses the first level as the baseline.
You can change this using contrasts and contr.treatment.

 e.g. To use treatment effects on Pipe with level 2 as the baseline:

contrasts(values$Pipe) <- contr.treatment(3, base = 2)
g2 <- lm(Volume ~., values)
g2
See ?read.table, ?contrasts, ?contr.treatment