prob3 <- read.table("http://www.stat.ufl.edu/~winner/data/hairyarn.dat", header=F,col.names=c("twist","speed","bobbin","hair")) attach(prob3) twist <- factor(twist) ### Make twist a factor (not numeric) variable speed <- factor(speed) ### " speed " " " " " bobbin <- factor(bobbin) ### " bobbin " " " " " ## Obtain cell means for twist:speed tapply(hair, list(twist, speed), mean) ## Obtain marginal means for twist, speed, bobbin tapply(hair, twist, mean) tapply(hair, speed, mean) tapply(hair, bobbin, mean) mod1 <- aov(hair ~ twist*speed + bobbin) summary(mod1) interaction.plot(twist,speed,hair) mod2 <- aov(hair ~ twist + speed + bobbin) summary(mod2) TukeyHSD(mod2,"twist") TukeyHSD(mod2,"speed")