p1 <- airquality |>ggplot(aes(x=Temp, fill=Month)) +geom_histogram(position="identity")+scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September")) +labs(x ="Monthly Temperatures from May - Sept", y ="Frequency of Temps",title ="Histogram of Monthly Temperatures from May - Sept, 1973",caption ="New York State Department of Conservation and the National Weather Service") #provide the data source
##Display plot 1
p1
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
##Improve on initial design
p2 <- airquality |>ggplot(aes(x=Temp, fill=Month)) +geom_histogram(position="identity", alpha=0.5, binwidth =5, color ="white")+scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September")) +labs(x ="Monthly Temperatures from May - Sept", y ="Frequency of Temps",title ="Histogram of Monthly Temperatures from May - Sept, 1973",caption ="New York State Department of Conservation and the National Weather Service")
##Display plot 2
p2
##Create side-by-side boxplots
p3 <- airquality |>ggplot(aes(Month, Temp, fill = Month)) +labs(x ="Months from May through September", y ="Temperatures", title ="Side-by-Side Boxplot of Monthly Temperatures",caption ="New York State Department of Conservation and the National Weather Service") +geom_boxplot() +scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September"))
##Display plot 3
p3
##Create the boxplots in grayscale
p4 <- airquality |>ggplot(aes(Month, Temp, fill = Month)) +labs(x ="Monthly Temperatures", y ="Temperatures", title ="Side-by-Side Boxplot of Monthly Temperatures",caption ="New York State Department of Conservation and the National Weather Service") +geom_boxplot()+scale_fill_grey(name ="Month", labels =c("May", "June","July", "August", "September"))
##Display plot 4
p4
##Plot 5
p5 <- airquality |>ggplot(aes(Month, Ozone, fill = Month)) +labs(x ="Months from May through September", y ="Ozone Readings", title ="Boxplot of Monthly Ozone Readings",caption ="New York State Department of Conservation and the National Weather Service") +geom_boxplot() +scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September"))
##display plot 5
p5
Warning: Removed 37 rows containing non-finite outside the scale range
(`stat_boxplot()`).
##This boxplot shows the correlation between temperature and ozone layer readings as when temperature rises, ozone readings seem to rise as shown by the boxplot showing ozone readings looks very similar in overall shape to the one comparing monthly temperature. I found this very intresting as I expected the opposite to happen, I would assume during peak summer, there would be less ozone since it would break down absorbing a lot more direct UV from the sun. I used the same code as the colored boxplot before however I changed the y variable in the chunk to Ozone instead of Temperature.