The downloaded binary packages are in
/var/folders/9f/_ykbhh0579j69vwc3rt8ryl40000gn/T//RtmpMlREfB/downloaded_packages
library(nycflights23)data(flights)
2. Change the labels needed for the plot, add the complete airport/airline labels, and use to break the text into multiple lines to fit on the bar graph.
3. Filter the dataset for flights with arrival delays greater than 0 (to exclude early arrivals from the average) exclude missing values, and select the top 3 worst airlines per airport.
5. Create a bar plot to visualize the top 3 worst airlines with the highest average arrival delays per airport.
ggplot(flights_filtered, aes(x = origin, y = mean_arr_delay, fill = Airlines)) +geom_bar(stat ="identity", position ="dodge") +scale_fill_manual(values =c("red", "blue", "darkgreen", "lightblue"),labels = airline_names) +scale_x_discrete(labels = airport_names) +labs(title ="Top 3 Airlines with the Worst Average\n Arrival Delays at NYC Airports",x ="Airport Origin",y ="Average Arrival Delay (min)",caption ="Source: FAA Aircraft registry" ) +theme_minimal() +theme(legend.title =element_text(size =12) )
This bar plot displays the three airlines with the worst average arrival delays at New York City’s major airports: John F. Kennedy (JFK), La Guardia (LGA), and Newark (EWR). Each bar represents an airline’s average delay (in minutes), with colors distinguishing specific carriers, including American Airlines (AA), JetBlue (B6), Frontier (F9), and SkyWest (OO). The legend on the right helps viewers easily identify each airline. The visualization highlights variations in airline performance across airports, showing that the worst-performing airlines in terms of delays differ by location. Notably, Frontier only operates at La Guardia, which travelers should consider when booking flights. Carriers such as American Airlines and SkyWest, which serve all three airports, also exhibit a trend of arrival delays. By focusing on the top three worst-performing airlines per airport, the plot emphasizes the significance of location-specific performance. This information can help passengers who prioritize punctuality make informed travel decisions. Additionally, it provides airlines with valuable insights for analyzing trends, optimizing flight schedules, and addressing operational challenges at each airport. Carriers operating at multiple locations, like American Airlines and SkyWest, can compare their performance across airports and implement strategies to improve service efficiency.
References
Subset rows using their positions - slice. - slice • dplyr. (n.d.). https://dplyr.tidyverse.org/reference/slice.html
OpenAI. (2025). ChatGPT (Mar. 1 version) [Large language model]. https://openai.com/chatgpt (it suggested using options(repos = c(CRAN = “https://cran.rstudio.com”)) to resolve an error when I was installing the nycflights23 package in R)