#install.packages("tidyverse")
#install.packages("readxl")
library(readxl)
## Warning: package 'readxl' was built under R version 4.1.3
#Load in data
my_mnm <- read_excel("Class_MnM_Data.xlsx", sheet = 1)
summary(my_mnm)
## student_id id color defect
## Length:382 Min. : 1.0 Length:382 Length:382
## Class :character 1st Qu.:10.0 Class :character Class :character
## Mode :character Median :20.0 Mode :character Mode :character
## Mean :22.8
## 3rd Qu.:35.0
## Max. :55.0
## total weight_grams
## Min. :18.00 Min. :25.00
## 1st Qu.:27.00 1st Qu.:40.00
## Median :54.00 Median :48.00
## Mean :45.01 Mean :44.25
## 3rd Qu.:55.00 3rd Qu.:50.00
## Max. :56.00 Max. :50.00
table(my_mnm$color)
##
## bl br g o r y
## 82 56 51 87 47 59
table(my_mnm$defect)
##
## c l m z
## 33 42 9 298
table(my_mnm$color, my_mnm$defect)
##
## c l m z
## bl 7 13 4 58
## br 2 3 0 51
## g 5 10 1 35
## o 6 8 2 71
## r 6 4 1 36
## y 7 4 1 47
barplot(table(my_mnm$color), col=c("blue","brown","green","orange",
"red","yellow"),main="My M&M Color Distribution")
bar_data <- table(my_mnm$defect, my_mnm$color)
barplot(bar_data)
barplot(bar_data, col = c("purple", "blue", "green", "gray"), legend.text = TRUE, args.legend = list(x = "topright", horiz = TRUE))
hist(my_mnm$weight_grams, col="blue",main="MnM Bag Weight in Grams", xlab="Weight in Grams", ylab="Frequency")
boxplot(my_mnm$total)
boxplot(my_mnm$total ~ my_mnm$color, xlab="Color",ylab="Grams",main="Box and Whisker",col=c("blue","brown","green","orange","red","yellow"))