In this chunk I am selecting the columns I will need for my graph and I am grouping the origin points. I have to select because the mutate function didn’t write over the origin values, it added a new column.
This chunk creates the bar graph, showing the average arrival delay, and colors the bars depending on if it’s high (red), or low (light beige). I am also labeling the axes, adding the title, and a caption of where the source came from.
ggplot(data = arr_avg, mapping =aes(x = airport_name, y = avg_delay, fill = avg_delay)) +geom_col() +labs(x ="Origin Points", y ="Average Arrival Delay", title ="The Average Arrival Delay For EWR, JFK, and LGA Airports", caption ="Source: Pre-built Dataset nycflights23", fill ="Arrival Delay High to Low") +scale_fill_gradient(low ="#fee8c8", high ="#e34a33")
The visualization I have created displays the average arrival delay for Newark, LaGuardia, and John F. Kennedy airports, and the main purpose of this was to see which airport on average has the longest average delays, and which one has the shortest average delays. In the flight dataset, arrival delay can be a negative number, 0, or a positive number. A negative number means that that flight arrived earlier than the estimated time, a 0 means it was on time, and a positive number means it arrived past the estimated time. The numbers represent minutes.
In my graph, I added a gradient to highlight a high number in average delays and low numbers. Red means a high number, and a light beige means a low number. I’d like to highlight from my graph that even though John F. Kennedy airport is not one of the high or low colors, since I’ve added a gradient, it becomes a color between the high and low colors. Looking at the legend, we can tell that the John F. Kennedy average arrival delay is closer to the high value, which makes the color closer to red, and we can determine the value through this, which would be 5-6, and looking at the graph can tell us that the value is a little less than 6 minutes. Looking at the finalized graph, we can see that Newark airport has the highest average delay time of about 7 minutes, and LaGuardia airport has the lowest average delay time with the value being less than 1 minute on average.