Code Appendix

HairEye <- read.csv("~/Downloads/HairEye.csv")
#Barplot
barplot(table(HairEye$Sex, HairEye$Eye), beside = TRUE, main = "Eye Color by Sex", xlab = "Eye Color", col = c("pink", "lightblue"), ylab= "Frequency", legend = rownames(table(HairEye$Sex, HairEye$Eye)))
#Mosiacplot
mosaicplot(table(HairEye$Sex, HairEye$Eye), main = "Mosiac Plot of Sex and Eye Color",col = c("blue", "brown", "green", "gray"))
#Histogram
hist(HairEye$GPA,xlab = "GPA",main = "Histogram of GPA")
#Boxplot
boxplot(HairEye$GPA ~ HairEye$Sex,
        col = c("pink", "lightblue"),
        horizontal = TRUE,
        main = "Grouped Boxplot of GPA by Gender",
        xlab = "GPA",
        ylab = "Gender")
#Boxplot
boxplot(HairEye$GPA ~ HairEye$Eye,
        col = c("blue", "brown", "green", "gray"),
        horizontal = TRUE,
        main = "Grouped Boxplot of GPA by Eye Color",
        xlab = "GPA",
        ylab = "Eye Color")

Problem a. Plot a barplot of sex and eye color

Women have a higher probablity of brown eyes

Problem b. Plot a mosaic plot of sex and eye color

There are more females than males in the study. The probability for blue eyes appears equal between male and females. The color green is the least common eye color for males.

Problem c. Plot a histogram of GPA

The most common interval of the GPA is 3.3-3.4 GPA.

Problem d. Plot a grouped boxplot of GPA by gender

Males have a lower median GPA. Males have more outliers than females.

Problem e. Plot a grouped boxplot of GPA by eye color.

The eye color hazel has the highest minimum. The eye color brown has the highest maximum.