data <- matrix(scan(),ncol=3,byrow=TRUE) 1 1 7.75 1 1 8.25 1 2 8.25 1 2 8.75 1 3 7.75 1 3 8.25 2 1 6.75 2 1 7.25 2 2 7.25 2 2 7.75 2 3 6.75 2 3 7.25 3 1 6.25 3 1 6.75 3 2 8.25 3 2 7.75 3 3 8.75 3 3 9.25 data HotDogs1 <- data.frame(data) colnames(HotDogs1) <- c("meat","salt","y") HotDogs1$meat <- as.factor(HotDogs1$meat) # to make sure that meat is a factor, not numeric HotDogs1$salt <- as.factor(HotDogs1$salt) # to make sure that salt is a factor, not numeric levels(HotDogs1$meat) <- c("beef","pork","chic") # names for the 3 levels of meat rm(data) HotDogs1 summary(lm(y ~ meat + salt + meat:salt, data = HotDogs1)) anova(lm(y ~ meat + salt + meat:salt, data = HotDogs1)) interaction.plot(HotDogs1$meat,HotDogs1$salt,HotDogs1$y,xlab="Types of meat", ylab="Taste score",main="Interaction of Meat and Salt") # nice plot showing the interaction HotDogs1$meatsalt <- as.numeric(HotDogs1$meat)*10 + as.numeric(HotDogs1$salt) # a way to obtain all factor combinations tapply(HotDogs1$y,HotDogs1$meatsalt,mean) # means for all factor combinations