library(multcomp) DF_I = read.csv('../../Data/ASCII_Comma/Chapter_12/watchi.txt', header=FALSE, col.names='Cycles') DF_I$Type = 'TypeI' DF_II = read.csv('../../Data/ASCII_Comma/Chapter_12/watchii.txt', header=FALSE, col.names='Cycles') DF_II$Type = 'TypeII' DF_III = read.csv('../../Data/ASCII_Comma/Chapter_12/watchiii.txt', header=FALSE, col.names='Cycles') DF_III$Type = 'TypeIII' DF = rbind( DF_I, DF_II, DF_III ) DF$Type = as.factor(DF$Type) fit = aov(Cycles ~ Type, data=DF) print(summary(fit)) #postscript("../../WriteUp/Graphics/Chapter12/prob_28_plotmeans.eps", onefile=FALSE, horizontal=FALSE) plotmeans(Cycles ~ Type, data=DF) #dev.off() # A Tukey comparison of means test: # TukeyHSD(fit) par(las=2) par(mar=c(5, 8, 4, 2)) plot(TukeyHSD(fit)) # Use the multcomp package: # par(las=2) par(mar=c(5, 4, 6, 2)) tuk = glht(fit, linfct=mcp(Type='Tukey')) plot(cld(tuk, level=0.05), col='lightgrey') # A nonparametric test for one-way ANOVA: # print(kruskal.test(Cycles ~ Type, data=DF))