library(reshape2) DF = read.table('../../Data/ASCII_Comma/Chapter_12/poisons.txt', sep=',', quote='\'', header=TRUE) colnames(DF) = c('poison', c('A', 'A1', 'B', 'B1', 'C', 'C1', 'D', 'D1')) DF_melt = melt(DF, id.vars='poison', variable.name='treatment', value.name='survival_time') mask = DF_melt$treatmen =='A1' DF_melt$treatment[mask] ='A' mask = DF_melt$treatment =='B1' DF_melt$treatment[mask] ='B' mask = DF_melt$treatment == 'C1' DF_melt$treatment[mask] ='C' mask = DF_melt$treatment =='D1' DF_melt$treatment[mask] ='D' DF_melt$poison = as.factor(DF_melt$poison) DF_melt$treatment = as.factor(DF_melt$treatment) # Consider the survival time directly: # fit = aov(survival_time ~ poison * treatment, data=DF_melt) print(summary(fit)) fit = aov(survival_time ~ poison + treatment, data=DF_melt) print(summary(fit)) # Consider the reciprical of the survival time: # DF_melt$one_over_survival_time = 1/DF_melt$survival_time fit = aov(one_over_survival_time ~ poison * treatment, data=DF_melt) print(summary(fit)) fit = aov(one_over_survival_time ~ poison + treatment, data=DF_melt) print(summary(fit))