Group by airlines, count the number of flights and take the mean of dep_delay
Grouping by airline the number of flights give us an idea of the carriers who are more relevant in the NYC context. From that, choose the top-4 carriers, adding the condition of at least 35000 flights operated in 2013.
It’s now time to put it all together. Using the “coord_flip” function you’ll flip the x and y axes. Labeling both axes and creating a legend is important to facilitate understanding and interpretation of the graph. Assigning colors through the “fill” function is also a feature that makes the visualization more interesting.
ggplot(top_four, aes(x = Airlines, y = delay, fill = Airlines)) +geom_bar(stat ="identity") +labs(x ="Airline names", y ="Delay in minutes", title ="Average Departure Delays of The Four \n Biggest Airlines at NYC in 2013") +coord_flip()
I created a visualization that shows the average departure delay in minutes of the four biggest airlines at NYC airports. All 4 airlines in the graph had at least 35000 flights leaving from NYC, so the data is relevant since it covers many flights. I also made sure to exclude all the “NA” values either in the “airlines” column (formerly called carrier), or in the “dep_delay” column. One aspect that caught my attention is the high average delay in the “ExpressJet” flights compared to the other airlines. I then searched the internet to know better about this carrier (honestly I’ve never heard before) and figured they filed for bankruptcy in August last year. I investigated if there was something to do with their poor customer experience (since punctuality is a vital aspect) but they went out of business mainly because of “stifled growth, rising costs and lower revenue due to the pandemic.”