# Make a boxplot of the data from chickwts plot(weight~feed,data = chickwts) # Create anova object weights.aov <- aov(weight ~ feed, data =chickwts) # Display the ANOVA table summary(weights.aov) # Display the grand mean and all group means, # plus group sizes model.tables(weights.aov,"means") # Perform Tukey's Honest Significant Difference Test # as post-hoc analysis posthoc <- TukeyHSD(weights.aov) # Result of analysis gives difference of means, and upper and lower # values of confidence interval, and adjusted p-value for that # pair of groups. posthoc # Plots the confidence intervals plot(posthoc) # Change the y axis to be perpendicular to the axis plot(posthoc,las = 1) # ------------ # Chi-Squared Goodness-of-Fit Test # observed values from sample observed = c(11,10) # expected probabilities probs = c(0.68,0.32) # perform the chi-square test chisq.test(observed,p = probs) # Make a table of only sex and eye color x = xtabs(Freq ~ Sex + Eye, data = HairEyeColor) # Perform a Chi-Squared Test comparing eye color # distribution in males and females chisq.test(x) # Make a table of only hair and eye color x = xtabs(Freq ~ Hair + Eye, data = HairEyeColor) # Display the table x # Perform the chi-squared test chisq.test(x)