Warning: `qplot()` was deprecated in ggplot2 3.4.0.
p1
Plot 2: Histogram using ggplot
ggplot is more sophisticated than qplot. Reorder the legend so that it is not the default (alphabetical), but in order that months come. Outline the bar in white using the color = “white” command.
Plot 3: Side-by-side boxplots categorized by Month
fill=Month command fills each boxplot with a different color in aesthetics. scale_fill_discrete makes the legends on the side for discrete color values. use “labs” to include the title, axis labels, caption for the data source.
This is a Side-by-side boxplots of Average Temperature by Month
p3 <- 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_discrete(name ="Month", labels =c("May", "June","July", "August", "September"))p3
Plot 4: Side-by-side boxplot in grey-scale
Use the scale_fill_grey command for the grey scale legend and use fill=Month in aesthetics
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
This histogram shows the frequency of wind each month. This is the best representation for these variables because each bar corresponds to the frequency or relative frequency of data within the particular range or interval. Looking at the graph, we see that wind at 10 occurs more often in July, the highest bar. In August, at wind 11, we see this is the second most occurring wind. Noticed the four outliers in the graph: May wind at about -2, July wind at 0, July wind at 20, and August wind at 21. These four data are considered outliers because they significantly deviate from the overall pattern of the dataset; they are distant from the other observations and show extreme values.
To make this modification, I used ggplot, changing the aes to x=Wind, fill=Month, position to “dodge”, alpha = 0.7, bindwidth = 5, color = “black”. I also changed the xlab to “Monthly Winds” and ggtitle to “Histogram of Monthly Winds”