data visual110

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.2     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.1.0     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(nycflights23)

data(flights)

Removing Na’s

flights_nona <- flights |>
  filter(!is.na(arr_delay))

Grouping by carrier, getting the average arrivel delay for each carrier and arranging in decending order to see which carrier had the longest delays.

bar_data <- flights_nona |>
  group_by(carrier) |>
  summarise(avg_arr_delay = mean(arr_delay)) |>
  arrange(desc(avg_arr_delay))

Graph

ggplot(bar_data, aes(x = carrier, y = avg_arr_delay , fill = avg_arr_delay,)) +
  geom_col(position = position_dodge(width = 1.6), width = .9) +
  scale_fill_gradient(low = "orange", high = "red", name = "average arrival delay in minutes") +
  labs (title = "Average Arrival Delays by Carriers in Minutes",
        x="carrier",
        y="average delay in minutes",
        caption= "Source: nycflights23 package") +
  theme_minimal() 

This visualization is of a bargraph showing the average delays by carriers in minutes using the nycflights23 package.To make this graph I first removed the na’s, then gruped by carriers and found the mean arrival delay for each carrier, next i set the axis and bar width,after that picked the colors and titled the legend, then gave the graph a title and titled the axes and gave it a caption, and latly selected a theme. The y axis shows the average delays in minutes and the x axis shows the carrier. The graphs color changes from orange to red depeding on the delay time of the carrier, it is more orange when delay is on the lower end and more red when delay is on the higher end. The graph makes it easy to see which carriers tend to have longer delays.