NYC Flights

Author

Sajutee Mukrabine

So many ways to visualize data

https://www.travelsavvy.agency/blog/what-airlines-fly-to-los-angeles

Use the dataset NYCFlights23 to explore late arrivals

Source: FAA Aircraft registry, https://www.faa.gov/licenses_certificates/aircraft_certification/ aircraft_registry/releasable_aircraft_download/

#install.packages("nycflights23") 
library(nycflights23) 
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.5.2     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.1.0     
── 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(flights) 
data(airlines)

#The average arrival delay per carrier and month

heatmap_data <- flights |>
  group_by(carrier, month) |>
  summarize(avg_arr_delay = mean(arr_delay, na.rm = TRUE)) |>
  arrange(desc(avg_arr_delay))
`summarise()` has grouped output by 'carrier'. You can override using the
`.groups` argument.

#Top 20 Destination Airports by Delayed Arrivals from NYC (FFA Codes)

ggplot(heatmap_data, aes(x = factor(month), y = carrier, fill = avg_arr_delay)) +
  geom_tile(color = "lightblue") +
  labs(
    title = "Top 20 Destination Airports by Dealyed Arrivals from NYC (FFA Codes)",
    x = "Month",
    y = "Airline Carrier",
    fill = "Avg Arrival Delay (mins)",
    caption = "Source: nycflights23 package"
  ) +
  scale_fill_gradient(low = "lavender", high = "red") +
  theme_minimal()

This heatmap is based on late arrival performance data for the nycflights23 dataset, an excerpt of all flights that left New York City in 2023. The months are represented on the x-axis, and the airline carriers are displayed by their carrier names on the y-axis. Each tile is shaded according to the airline’s average arrival delay for that month. The shades vary from lavender to red, and the darkest red colors indicate the most substantial delays.

One obvious thing to notice on this heatmap is that during winter, there are more delays across several airlines possibly due to snow or ice affecting flight schedules. Sign Up Airlines, as with flight prices, there are no guarantees while monitoring price points of individual airlines. But several are fairly reliable. This is an interesting visualization for comparing the performance of different airlines and shows how conditions are seasonal factors that lead to delays.