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.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ 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
library(nycflights23)
## Warning: package 'nycflights23' was built under R version 4.3.3
data(flights)

Focus on December 2023

new_flights <- flights |>
  filter(month >= 12)
by_hour <- new_flights |>
  group_by(time_hour) |>  
  summarise(count = n()) |> 
  arrange(time_hour) 
head(by_hour)
## # A tibble: 6 × 2
##   time_hour           count
##   <dttm>              <int>
## 1 2023-12-01 05:00:00     9
## 2 2023-12-01 06:00:00    86
## 3 2023-12-01 07:00:00    85
## 4 2023-12-01 08:00:00    92
## 5 2023-12-01 09:00:00    81
## 6 2023-12-01 10:00:00    66
by_hour <- by_hour |>
  mutate(
    date = as.Date(time_hour),
    hour = format(time_hour, "%H")
)

library(viridis)
## Loading required package: viridisLite
ggplot(by_hour, aes(x = date, y = hour, fill = count)) +
  geom_tile() +
  scale_fill_viridis_c(option = "A") +
  labs(title = "Flight Frequency Heatmap in December 2023",
    caption = "Source: FAA Aircraft registry",
    x = "Date",
    y = "Hour of Day",
    fill = "Flight Frequency #") +
  theme_minimal() 

My Heatmap is to visualize the frequency of flights in December 2023 out of NYC alongside the hour of day flights departed. When creating my heatmap, I thought of the winter season, flights to and from home for the holidays, end of semester travelling, etc, any events that could influence a spike or drop in flight frequency out of NYC. As a result, we can see the trend of little late-night flights, and some outliters for dates such as December 3/10/17 had a drop in flights because of being a Sunday (can be associated with inconvenience). Approaching the holiday weekend season around December 21, there is a drop in flight frequency with a darker gradient, most likely due to less demand (already flying out prior to the holidays), or weather conditions due to NYC’s climate and likely snow forecasts.

I acknowledge the use of ChatGPT(https://chat.openai.com/) to search for the “scale_fill_viridis_c(option =”A”)” and “format(time_hour,”%H”)” option in order to add better color and solve the issue of adding dates to my heatmap.