Warning: `qplot()` was deprecated in ggplot2 3.4.0.
plot1 #why is graph name needed at the end?
Plot 2: Histogram of Avg. Temp by Month
plot2 <- 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")) +#I don't understand the purpose of scale commandxlab("Temperature") +ylab("Frequency") +ggtitle("Monthly Temperatures")plot2 +theme(plot.title =element_text(hjust =0.5)) #center title name
Plot 3: Side-by-Side Boxplots of Avg Temp by Month
plot3 <- 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") +theme(plot.caption =element_text(hjust =0.0)) +#adjusted the captiongeom_boxplot() +scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September"))plot3 +theme(legend.key =element_blank()) #remove gray background from the legend
Plot 4: Side-by-Side Bloxplots - Gray Scale
plot4 <- 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"))plot4 +theme(legend.key =element_blank()) #remove gray background from the legend
help(airquality)
Plot 5: Histogram of Monthly Average Wind Speeds
plot5 <- airquality %>%ggplot(aes(x=Wind, fill=Month)) +geom_histogram(position="identity", alpha=0.5, binwidth =5, color ="white") +theme(panel.background =element_rect(fill="white")) +#create white background for the histogram labs(caption="Average wind speed in miles per hour at 0700 and 1000 hours at LaGuardia Airport") +scale_fill_discrete(name ="Month", labels =c("May", "June", "July", "August", "September")) +xlab("Wind Speed") +ylab("Average") +ggtitle("Monthly Average Wind Speed")plot5 +theme(plot.title =element_text(hjust =0.5)) #center title name
#I created a histogram looking at the average wind speed by month. #I modified the code from Plot 2 to create Plot 5. #I also found code online that helped with other aesthetics #(I made comments within the code), such as changing the #background of the histogram to white, adding a caption, #and centering the title name.