#loading libraries
library(nycflights13)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.1     ✔ purrr   1.0.1
## ✔ tibble  3.1.8     ✔ dplyr   1.1.0
## ✔ tidyr   1.3.0     ✔ stringr 1.5.0
## ✔ readr   2.1.3     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
#visualizing relationship between departure delay and arrival delay colored by carrier
ggplot(data = flights, aes(x = dep_delay, y = arr_delay, color = carrier)) +
  geom_point(alpha = 0.5) +
  xlab("Departure Delay") +
  ylab("Arrival Delay") +
  ggtitle("Arrival Delay vs. Departure Delay by Airline") +
  theme_bw() +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_color_discrete(name = "Airline")
## Warning: Removed 9430 rows containing missing values (`geom_point()`).