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 sourcep1
`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
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
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"))p4
Plot 5: Now make one plot on your own of any of the variables in this dataset. It may be a scatterplot, histogram, or boxplot.
p5 <- airquality |>ggplot(aes(x=Ozone, fill=Month)) +geom_histogram(position="identity", alpha=0.9, binwidth =5, color ="white")+scale_fill_discrete(name ="Month", labels =c("May", "June","July", "August", "September")) +labs(x ="Monthly Ozone Levels from May - Sept", y ="Ozone Frequency",title ="Histogram of Monthly Ozone Levels from May - Sept, 1973",caption ="New York State Department of Conservation and the National Weather Service")p5
Essay: The histogram above is a color-coded graph that illustrates the relationship between ozone levels, frequency, and months. When I first made the histogram, I looked for variables that could possibly be correlated and it was easy to pick the variables I wanted to use. The tutorial was very useful in helping me understand what certain commands do. In particular, I was fond of plot 2, which showed a histogram of temperature frequencies for every month. I outlined the bars using the white command and allowed the data to overlap. However I made a few adjustments. I noticed that when u change alpha, the colors also begin changing as well depending on if it is increased or decreased. Also, I noticed that the NAs were excluded from the histogram after putting in the commands to make the histogram. The colors of the ozone levels correspond to the color of the month and show each frequency. Lastly, I added one of the most important parts of the graph, the title, x, and y axis to make the histogram more readable.