# R Example of the Single-Factor ANOVA model # We will analyze the Kenton Foods data from the example in class # Save the data file into a directory and # use the full path name: kenton.data <- read.table(file = "z:/My Documents/teaching/stat_705/kentondata.txt", header=FALSE, col.names = c('sales', 'design', 'store')) # attaching the data frame: attach(kenton.data) # Making "design" a factor: design <- factor(design) # Fitting the ANOVA model and producing the ANOVA table: kenton.fit <- lm(sales ~ design); anova(kenton.fit) # Note the F* = MSTR/MSE = 18.59 here. # The fitted() function gives us the sample mean response for each of the # four designs. Compare the output to the table on page 688 of the book. cbind(design, fitted(kenton.fit)) #####################################################################################