flights |>filter(!is.na(dep_delay), !is.na(day)) |>group_by(carrier, day) |>summarise(avg_delay =mean(dep_delay)) |>ggplot(aes(x = day, y = carrier, fill = avg_delay)) +geom_tile() +scale_fill_gradient(low ="pink", high ="red") +labs(title ="Average Departure Delay by Carrier and Day of Week",x ="Day",y ="Carrier",fill ="Average Delay (in minutes)",caption ="Source: NYC Flights Dataset")
`summarise()` has grouped output by 'carrier'. You can override using the
`.groups` argument.
The visualization created is a heatmap illustrating the average departure delay by carrier against what day those flights were. Each cell in the heatmap represents the average departure delay (in minutes) for a specific carrier on a particular day of the week. The color gradient ranging from pink to red indicates the magnitude of the average delay with brighter red shades representing longer delays.
One aspect of the plot worth highlighting is the variation in departure delays across different carriers and days of the week.This can be used to identify patterns and trends, such as which carriers tend to experience more delays on certain days.