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
Plot 1 Output
p1
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Improve the histogram of Average Temperature by Month
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")
Plot 2 Output
p2
Plot 3: Create side-by-side boxplots categorized by Month
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"))
Plot 3 Output
p3
Plot 4: Side by Side Boxplots in Gray Scale
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"))
Plot 4 Output
p4
side-by-side boxplots of monthly wind
p5 <- airquality |>ggplot(aes(Month, Wind, fill = Month)) +labs(x ="Months from May through September", y ="Wind", title ="Side-by-Side Boxplot of Monthly Wind",caption ="New York State Department of Conservation and the National Weather Service") +geom_boxplot() +scale_fill_viridis_d(name ="Month", labels =c("May", "June","July", "August", "September"))
p5
In this code I made a side-by-side boxplot of the monthly wind from May-September. This plot shows the minimum, maximum, and mean Wind in the months May-September. The minimum and maximum are shown by the black vertical lines that are above and below the boxes and the mean is shown by the horizontal lines that are in the boxes. The code here is similar to the Side-by-Side Boxplot of Monthly Temperatures but I changed Temperatures to Wind. I also changed the colors by using scale_fill_viridis_d.