Load Data

data("airquality")
head(airquality)
##   Ozone Solar.R Wind Temp Month Day
## 1    41     190  7.4   67     5   1
## 2    36     118  8.0   72     5   2
## 3    12     149 12.6   74     5   3
## 4    18     313 11.5   62     5   4
## 5    NA      NA 14.3   56     5   5
## 6    28      NA 14.9   66     5   6

Summary Statistics

mean(airquality$Temp)
## [1] 77.88235
mean(airquality[,4])
## [1] 77.88235
median(airquality$Temp)
## [1] 79
sd(airquality$Wind)
## [1] 3.523001
var(airquality$Wind)
## [1] 12.41154

Rename Months

airquality1 <- airquality |>
  mutate(month_name = case_when(
    Month == 4 ~ "April",
    Month == 5 ~ "May",
    Month == 6 ~ "June",
    Month == 7 ~ "July",
    Month == 8 ~ "August",
    Month == 9 ~ "September"))

summary(airquality1$month_name)
##    Length     Class      Mode 
##       153 character character
airquality1$Month <- factor(
  airquality1$month_name,
  levels=c("May","June","July","August","September")
)

Plot 1

p1 <- airquality1 |>
  ggplot(aes(x=Temp, fill=month_name)) +
  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 `binwidth`.

Plot 2

p2 <- airquality1 |>
  ggplot(aes(x=Temp, fill=month_name)) +
  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

p3 <- airquality1 |>
  ggplot(aes(Month, Temp, fill=month_name)) +
  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

p4 <- airquality1 |>
  ggplot(aes(Month, Temp, fill=month_name)) +
  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 <- airquality1 |>
  ggplot(aes(x=Wind,y=Temp,color=month_name))+
  geom_point(size=3,alpha=0.7)+
  labs(
    title="Relationship Between Wind Speed and Temperature",
    x="Wind Speed (mph)",
    y="Temperature (°F)",
    caption="Data Source: New York State Department of Conservation and the National Weather Service"
  )+
  scale_color_discrete(name="Month")
p5

Plot 5 Description

The plot I created is a scatterplot showing the relationship between wind speed and temperature. Each point represents one day, and the colors represent the months from May through September.

The plot suggests that warmer temperatures are generally associated with lower wind speeds, while cooler temperatures often occur when wind speeds are higher. Although the relationship is not perfect, there is a slight negative trend.

I used geom_point() to create the scatterplot. I used color = month_name to display each month in a different color. I also used alpha = 0.7 to make overlapping points easier to see, and labs() to add the title, axis labels, and data source caption.