ggplot(airport_delays, aes(x = origin, y = avg_delay, fill = origin)) +geom_col()
airport_delays <- airport_delays %>%mutate(origin =recode(origin,"EWR"="Newark Liberty International Airport","JFK"="John F. Kennedy International Airport","LGA"="LaGuardia Airport" ))ggplot(airport_delays, aes(x = origin, y = avg_delay, fill = origin)) +geom_col() +labs(title ="Average Departure Delay by Airport in 2023",x ="Airport",y ="Average Departure Delay (Minutes)",fill ="Airport",caption ="Source: nycflights23 flights dataset" ) +theme(axis.text.x =element_text(angle =45, hjust =1))
For this visualization, I made a bar graph comparing the average departure delay at John F. Kennedy International Airport, LaGuardia Airport, and Newark Liberty International Airport during 2023. The data came from the flights dataset in the nycflights23 package. I wanted to see how much the average delay differed between these three airports. The airport names are along the bottom, and the numbers on the left show the delay in minutes. I used a separate color for each airport so it would be easy to tell the bars apart. Before making the graph, I grouped the flights by where they departed and found the average delay for each group. Flights without a departure delay recorded were left out of that calculation. What stood out to me most was LaGuardia. Its average was about 10.8 minutes, compared to 15.9 minutes at John F. Kennedy and 15.4 minutes at Newark. The other two were pretty close, but LaGuardia was about five minutes lower. This calculation also includes flights that left early. Looking at the graph, I can see which airport had the lowest average, but I would need to look into the data more to figure out why.