library(reshape2) library(gplots) DF = read.csv('../../Data/ASCII_Comma/Chapter_12/niacin.txt', quote='\'') DF_melt = melt(DF, id.vars=c('Lab'), variable.name='Cereal', value.name='MG_Niacin') DF_melt$Lab = as.factor(DF_melt$Lab) print('Missing data to be dropped:') print(DF_melt[!complete.cases(DF_melt),]) DF_melt = DF_melt[complete.cases(DF_melt), ] fit = aov(MG_Niacin ~ Lab * Cereal, data=DF_melt) print(summary(fit)) #postscript("../../WriteUp/Graphics/Chapter12/prob_24_interactionplot.eps", onefile=FALSE, horizontal=FALSE) interaction.plot(DF_melt$Lab, DF_melt$Cereal, DF_melt$MG_Niacin, type='b', xlab='Laboratory', ylab='Niacin (MG)', main='Interaction between Lab and Cereal') #dev.off()