NYC flights 2013 BarChart

Author

Ryan Nicholas

#install.packages("nycflights13")
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.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── 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(nycflights13)

data(flights)

Below I make my overall data set I will use to plot for this I made the months into words and got a count value and also recorded the flight origins

by_origins <- flights |>
  mutate(month = month(month, label = TRUE))|>
  group_by(origin,month) |> 
  summarise(count = n())
`summarise()` has grouped output by 'origin'. You can override using the
`.groups` argument.
head(by_origins)
# A tibble: 6 × 3
# Groups:   origin [1]
  origin month count
  <chr>  <ord> <int>
1 EWR    Jan    9893
2 EWR    Feb    9107
3 EWR    Mar   10420
4 EWR    Apr   10531
5 EWR    May   10592
6 EWR    Jun   10175

This is me making the bar chart to graph it all.

ggplot(data = by_origins) +
 geom_col (aes(x = origin, y = count, fill = month), position = "dodge") +
 labs(x = "Airport Origin", 
      y = "Flights Left",
      title = "Number Of Flights Left From NYC Airports\nEach month",  
      fill = "Month", 
      caption = "Source: FAA Aircraft registry\nhttps://www.faa.gov/licenses_certificates/aircraft_certification/ aircraft_registry/releasable_aircraft_download/") +
 theme(legend.key.size = unit(3, 'mm'), 
       plot.title = element_text(hjust = 0.5), 
       plot.caption = element_text(hjust = 0.5))

For this visualization it took me a long time to come up with what I wanted to do. I tried multiple different things till I finally decided to do a bar graph because its what I liked the most visual wise. For this particular visualization I was really curious to see if the flight frequencies had variation between months and also origin locations and I figured out there were only very slight differences and they were not that noticeable which is what this chart shows. Id like to highlight my use of the theme tool, with this I could edit the text of my graph making my graph more readable. I also really like the colors of my chart and I feel they look very appealing.