Plot 1: Create a histogram categorized by Month```
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") p1
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Plot 2: Improve the Histogram using ggplot
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")p2
Plot 3: Create side-by-side boxplots categorized by Month
August has the highest temperatures based on the boxplot distribution.
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"))p3
Plot 4: Make the same side-by-side boxplots, but in grey 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"))p4
Plot 5:
p5<- airquality |>ggplot(aes(Month, Temp, fill= Month))+labs(x ="Months from May through September", y="Temperatures", title="Scatter Plot of Monthly temperatures by days",caption="New York State Department of Conservation and the National Weather Service") +geom_point(col="blue")+scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September"))p5
As stated by my graph’s title, this graph represents the monthly temperature by days.I used a scatter plot to represent it by adding the “geom_point” function. As you can see on the graph; June,July,August, and September had most of their days with a temperature equal to or higher than 8o degrees, while May only had one day in which the temperature was over 80 degrees.