HW WEEK 2

Author

Dajana R

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
data("airquality")
p1 <- airquality |>
  ggplot(aes(x=Temp)) +
  geom_histogram(aes(fill = factor(Month)),position="identity", bins = 30)+
  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 source
p1

p2 <- airquality |>
  ggplot(aes(x=Temp, )) +
  geom_histogram(aes(fill = factor(Month)),position="identity", alpha=0.5, binwidth = 5, color = "white", bins = 30)+
  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

p3 <- airquality |>
  ggplot(aes(x = factor(Month), y = Temp, fill = factor(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 

p4 <- airquality |>
  ggplot(aes(x = factor(Month), y = Temp, fill = factor(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

p5 <- airquality |>
ggplot(aes(x = Wind, y = Month, color = factor(Month))) +
  labs(y = "Month", x= "Wind Speed", title = "Scatterplot of Monthly Wind Speed",
       caption = "New York State Department of Conservation and the National Weather Service") +
  geom_point(position = position_jitter(width = 0.5, height = 0.5), size = 4) +
  scale_color_discrete(name = "Months", labels = c("May", "June", "July", "August", "September"))
p5

Be sure to write a brief essay that describes the plot you have created, what the plot shows, and what code you used to make this modification.

The scatterplot demonstrates the relationship, between wind speed and the months of May trought September in the air quality dataset. Each point on the plot represents observations, with the x axis showing wind speed and the y axis representing the months. To make it clearer and prevent overlap a slight jitter is applied using the position jitter function. Color coding is used to differentiate between months making it easier to identify and compare them. The legend, labeled “Months” serves as a guide by providing full month names as labels for understanding the colors used. In summary this scatterplot effectively demonstrates how wind speed varies throughout these months. It provides insights into patterns or trends. The deliberate use of color enhances interpretation. It ensures that both quick observations and detailed analysis can be easily done. By making these code modifications we achieve a visualization that depicts the relationship, between wind speed and months.

**CHATGTP Was used to modify and understand the coding of the plots. Plots 1-4 needed a bit of fixing in my code because the colors would not show up.I asked CHATGTP what was wrong with my code and it helped me resolve what was wrong.