Question 1

Planes that fly LGA to XNA
Q1 <- 
  full_join(
    flights, 
    planes, 
    by = "tailnum"
    ) %>% 
  filter(
    origin == "LGA", 
    dest == "XNA"
    ) %>% 
  select(
    origin, 
    dest, 
    tailnum, 
    manufacturer, 
    model
    ) %>% 
  distinct(
    tailnum, 
    .keep_all = TRUE
    ) %>% 
  arrange(tailnum)
head(Q1)
## # A tibble: 6 × 5
##   origin dest  tailnum manufacturer model
##   <chr>  <chr> <chr>   <chr>        <chr>
## 1 LGA    XNA   N0EGMQ  <NA>         <NA> 
## 2 LGA    XNA   N501MQ  <NA>         <NA> 
## 3 LGA    XNA   N507MQ  <NA>         <NA> 
## 4 LGA    XNA   N510MQ  <NA>         <NA> 
## 5 LGA    XNA   N511MQ  <NA>         <NA> 
## 6 LGA    XNA   N512MQ  <NA>         <NA>

Question 2

Add airline name to flights table
Q2 <-
  left_join(
    flights, 
    airlines, 
    by = "carrier"
  ) %>% 
  mutate(date = as.Date(paste(
    year, 
    month, 
    day, 
    sep = "-"
  ))) %>% 
  select(
    date, 
    carrier, 
    name, 
    flight, 
    tailnum, 
    origin, 
    dest, 
    dep_time, 
    arr_time, 
    dep_delay, 
    arr_delay
  ) %>% 
  arrange(
    date, 
    dep_time,
    flight
  )
head(Q2)
## # A tibble: 6 × 11
##   date       carrier name          flight tailnum origin dest  dep_time arr_time
##   <date>     <chr>   <chr>          <int> <chr>   <chr>  <chr>    <int>    <int>
## 1 2013-01-01 UA      United Air L…   1545 N14228  EWR    IAH        517      830
## 2 2013-01-01 UA      United Air L…   1714 N24211  LGA    IAH        533      850
## 3 2013-01-01 AA      American Air…   1141 N619AA  JFK    MIA        542      923
## 4 2013-01-01 B6      JetBlue Airw…    725 N804JB  JFK    BQN        544     1004
## 5 2013-01-01 DL      Delta Air Li…    461 N668DN  LGA    ATL        554      812
## 6 2013-01-01 UA      United Air L…   1696 N39463  EWR    ORD        554      740
## # ℹ 2 more variables: dep_delay <dbl>, arr_delay <dbl>

Question 3

Airports with no commercial flights (neither leaving nor arriving)
Q3 <- 
  anti_join(
    airports, 
    flights,
    by = c("faa" = "origin")
  ) %>% 
  anti_join(
    flights, 
    by = c("faa" = "dest")
  ) %>% 
  select(
    faa, 
    name, 
    alt, 
    dst, 
    tzone
  )
head(Q3)
## # A tibble: 6 × 5
##   faa   name                             alt dst   tzone           
##   <chr> <chr>                          <dbl> <chr> <chr>           
## 1 04G   Lansdowne Airport               1044 A     America/New_York
## 2 06A   Moton Field Municipal Airport    264 A     America/Chicago 
## 3 06C   Schaumburg Regional              801 A     America/Chicago 
## 4 06N   Randall Airport                  523 A     America/New_York
## 5 09J   Jekyll Island Airport             11 A     America/New_York
## 6 0A9   Elizabethton Municipal Airport  1593 A     America/New_York

Question 4

Windiest airports, in descending order, as measured by the number of times wind speeds were greater than 30
Q4 <-
  right_join(
    airports, 
    weather %>% 
      filter(wind_speed > 30) %>% 
      group_by(origin) %>% 
      summarise(high_winds = sum(!is.na(wind_speed))), 
    by = c("faa" = "origin")
  ) %>% 
  arrange(desc(high_winds)) %>% 
  select(name)
head(Q4)
## # A tibble: 3 × 1
##   name               
##   <chr>              
## 1 John F Kennedy Intl
## 2 La Guardia         
## 3 Newark Liberty Intl