# ANOVASoTL.R # ANOVA for SoTL #----------------------------------------------------------------------------- # Import Data From Spreadsheet (Step 1) df = read.table(file = "clipboard", sep = "\t", header = TRUE); df; # if you did this right, you will see the students' data in the R console. #----------------------------------------------------------------------------- # Boxplots of Data (Step 2) boxplot(df$Test ~ df$Major,col = "cyan", main = "Boxplots of students' test scores by major."); boxplot(df$Test ~ df$Flavor,col = c("brown", "yellow"), main = "Boxplots of students' test scores by favorite flavor."); boxplot(df$Test ~ df$Flavor*df$Major,col = "green", main = "Boxplots of students' test scores by major x favorite flavor."); #----------------------------------------------------------------------------- # Perform the ANOVA (Step 3) dfANOVA <- aov(Test ~ Major * Flavor, data = df); summary(dfANOVA); # you should see the ANOVA table in the R console. #----------------------------------------------------------------------------- # Make a table with means and standard deviations sd (Step 4) # for main effects agMajor = aggregate(Test~Major, df, function(x) c(mean = mean(x), sd = sd(x),n = length(x))); agMajor; agFlavor = aggregate(Test~Flavor, df, function(x) c(mean = mean(x), sd = sd(x), n = length(x))); agFlavor ; # for interaction effects agMajorFlavor = aggregate(Test~Major*Flavor, df, function(x) c(mean = mean(x), sd = sd(x),n = length(x))); agMajorFlavor; #----------------------------------------------------------------------------- # End of script