Question 1: Flights with the longest departure delays

This code sorts the flights dataset to find the flights with the largest departure delays.

flights %>%
  filter(!is.na(dep_delay)) %>%
  arrange(desc(dep_delay)) %>%
  select(year, month, day, carrier, flight, origin, dest, dep_delay) %>%
  head(10)
## # A tibble: 10 × 8
##     year month   day carrier flight origin dest  dep_delay
##    <int> <int> <int> <chr>    <int> <chr>  <chr>     <dbl>
##  1  2013     1     9 HA          51 JFK    HNL        1301
##  2  2013     6    15 MQ        3535 JFK    CMH        1137
##  3  2013     1    10 MQ        3695 EWR    ORD        1126
##  4  2013     9    20 AA         177 JFK    SFO        1014
##  5  2013     7    22 MQ        3075 JFK    CVG        1005
##  6  2013     4    10 DL        2391 JFK    TPA         960
##  7  2013     3    17 DL        2119 LGA    MSP         911
##  8  2013     6    27 DL        2007 JFK    PDX         899
##  9  2013     7    22 DL        2047 LGA    ATL         898
## 10  2013    12     5 AA         172 EWR    MIA         896

Question 2: Was there a flight every day in 2013?

This code counts the number of days that had flights recorded in the dataset.

flights %>%
  count(year, month, day) %>%
  summarise(days_with_flights = n())
## # A tibble: 1 × 1
##   days_with_flights
##               <int>
## 1               365