library(reshape2) library(gplots) library(multcomp) DF = read.csv('../../Data/ASCII_Comma/Chapter_12/diet-and-longevity.txt', quote='\'', header=TRUE) #postscript("../../WriteUp/Graphics/Chapter12/prob_33_boxplot.eps", onefile=FALSE, horizontal=FALSE) boxplot(LIFETIME ~ DIET, data=DF) #plotmeans(LIFETIME ~ DIET, data=DF) #dev.off() fit = aov(LIFETIME ~ DIET, data=DF) print(summary(fit)) # A Tukey comparison of means test: # TukeyHSD(fit) #postscript("../../WriteUp/Graphics/Chapter12/prob_33_TukeyHSD_plot.eps", onefile=FALSE, horizontal=FALSE) par(las=2) par(mar=c(5, 8, 4, 2)) plot(TukeyHSD(fit)) #dev.off() # Use the multcomp package: # par(las=2) par(mar=c(5, 4, 6, 2)) tuk = glht(fit, linfct=mcp(DIET='Tukey')) plot(cld(tukr, level=0.05), col='lightgrey') # A nonparametric test for one-way ANOVA: # print(kruskal.test(LIFETIME ~ DIET, data=DF))