Load necessary libraries

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Plot 1: Create a histogram categorized by Month

p1 <- airquality |>
  ggplot(aes(x = Temp, fill = factor(Month))) +
  geom_histogram(position = "identity", color = "black", bins = 30) + # Specify color and number of bins
  scale_fill_manual(name = "Month",  # Manually specify fill colors
                    values = c("blue", "green", "red", "orange", "purple")) +
  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

# Plot 2: Improved histogram using ggplot

p2 <- airquality |>
  ggplot(aes(x = Temp, fill = factor(Month))) +
  geom_histogram(position = "identity", alpha = 0.5, bins = 30, color = "black") + # Specify color and number of bins
  scale_fill_manual(name = "Month", 
                    values = c("blue", "green", "red", "orange", "purple")) +
  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: Side-by-side boxplots categorized by Month

p3 <- airquality |>
  ggplot(aes(x = factor(Month), y = Temp, fill = factor(Month))) + 
  geom_boxplot() +
  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") +
  scale_fill_manual(name = "Month", 
                    values = c("blue", "green", "red", "orange", "purple"),
                    labels = c("May", "June", "July", "August", "September")) +
  theme_minimal()
p3

# Plot 4: Side-by-side boxplots in grayscale

p4 <- airquality |>
  ggplot(aes(x = factor(Month), y = Temp, fill = factor(Month))) + 
  geom_boxplot() +
  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") +
  scale_fill_grey(name = "Month", 
                  labels = c("May", "June", "July", "August", "September")) +
  theme_minimal()
p4

# Plot 5: Scatterplot of Ozone levels vs. Wind speed

p5 <- airquality |>
  ggplot(aes(x = Wind, y = Ozone)) +
  geom_point() +  # Add points for each observation
  geom_smooth(method = "lm", se = FALSE, color = "blue") +  # Add a regression line
  labs(x = "Wind Speed", 
       y = "Ozone Level", 
       title = "Scatterplot of Ozone Level vs. Wind Speed",
       caption = "Data Source: New York State Department of Conservation and the National Weather Service") +
  theme_minimal()
p5
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 37 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 37 rows containing missing values or values outside the scale range
## (`geom_point()`).

The scatterplot of Ozone levels vs. Wind speed visualizes the relationship between these two variables in the air quality dataset. Each point on the plot represents a daily observation of Ozone level and Wind speed recorded over a period of five months from May to September 1973. W ggplot() is used to specify the aesthetics, with Wind speed on the x-axis and Ozone level on the y-axis. geom_point() adds points for each observation in the dataset. geom_smooth(method = “lm”, se = FALSE, color = “blue”) adds a linear regression line to the plot, with the option se = FALSE to remove the shaded confidence interval. We specify the color of the regression line as blue. labs() is used to add labels to the axes, title, and caption. theme_minimal() is applied to give the plot a clean appearance.