library(ggplot2)ggplot(avg_delay, aes(x = month, y = carrier, fill = avg_dep_delay)) +geom_tile() +scale_fill_gradient(low ="lightblue", high ="purple") +labs(title ="Average Departure Delay by Airline and Month",x ="Month",y ="Airline",fill ="Avg Departure Delay (minutes)")+theme_minimal() +theme(axis.text.x =element_text(angle =45, hjust =1)) +guides(fill =guide_colorbar(title ="Avg Departure Delay\n(minutes)"))
The heatmap visualizes the average departure delays for various airlines across different months of the year. Each cell in the heatmap is a unique combination of an airline and a month, colored according to the average departure delay in minutes. The color gradient from lightblue to purple indicates the size of the delay, with lighter colors representing shorter delays and darker colors representing longer delays. One aspect of the plot to highlight is the seasonal variation in delays for specific airlines, which can provide insights into operational challenges faced during certain times of the year. This visualization helps in identifying patterns and trends in airline performance over time. Running the entire code should allow you to generate a heatmap with the specified color scheme that shows the average departure delays, giving you information about the performance and delays of the airline.