library(reshape2) library(gplots) DF = read.csv('../../Data/ASCII_Comma/Chapter_12/magnesium.txt', header=FALSE) colnames(DF) = sprintf('Pos%d', seq(10)) # position DF$Bar = rep( seq(5), 2 ) DF_melt = melt(DF, id.vars=c('Bar'), variable.name='Position', value.name='MG') DF_melt$Bar = as.factor(DF_melt$Bar) DF_melt$Position = as.factor(DF_melt$Position) fit = aov(MG ~ Position * Bar, data=DF_melt) print(summary(fit)) #postscript("../../WriteUp/Graphics/Chapter12/prob_25_interactionplot.eps", onefile= FALSE, horizontal=FALSE) interaction.plot(DF_melt$Bar, DF_melt$Position, DF_melt$MG, type='l', main='Interaction between Bar and Position' ) #dev.off()