use the below code to look at the data - DO NOT ADD VIEW STATEMENTS TO RMARKDOWN

Create the code makes a table for each of the below questions.

1. join + filter - Which airplanes fly LGA to XNA (1 POINT)

q1 <- flights %>% 
  filter(origin == "LGA" , dest == "XNA") %>% 
  left_join(planes, by = "tailnum") %>% 
  select(model) %>% 
  distinct()

knitr::kable(head(q1))
model
NA
G1159B
172N
CF-5D
CL-600-2C10

2. join - Add the airline name to the flights table (1 POINT)

q2 <- flights %>% 
  left_join(airlines , by = "carrier") %>% 
  select(carrier, name, year, month, day, dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay, carrier, flight, tailnum, origin, dest, air_time, distance, hour, minute, time_hour)


knitr::kable(head(q2))
carrier name year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay flight tailnum origin dest air_time distance hour minute time_hour
UA United Air Lines Inc. 2013 1 1 517 515 2 830 819 11 1545 N14228 EWR IAH 227 1400 5 15 2013-01-01 05:00:00
UA United Air Lines Inc. 2013 1 1 533 529 4 850 830 20 1714 N24211 LGA IAH 227 1416 5 29 2013-01-01 05:00:00
AA American Airlines Inc. 2013 1 1 542 540 2 923 850 33 1141 N619AA JFK MIA 160 1089 5 40 2013-01-01 05:00:00
B6 JetBlue Airways 2013 1 1 544 545 -1 1004 1022 -18 725 N804JB JFK BQN 183 1576 5 45 2013-01-01 05:00:00
DL Delta Air Lines Inc. 2013 1 1 554 600 -6 812 837 -25 461 N668DN LGA ATL 116 762 6 0 2013-01-01 06:00:00
UA United Air Lines Inc. 2013 1 1 554 558 -4 740 728 12 1696 N39463 EWR ORD 150 719 5 58 2013-01-01 05:00:00

3. join + select + distinct() - Which airports have no commercial flights (1 POINT)

q3 <- airports %>% 
  anti_join(flights, by = c("faa" = "origin")) %>%
  anti_join(flights, by = c("faa" = "dest")) %>%
  select(faa, name) %>%
  distinct()

knitr::kable(head(q3))
faa name
04G Lansdowne Airport
06A Moton Field Municipal Airport
06C Schaumburg Regional
06N Randall Airport
09J Jekyll Island Airport
0A9 Elizabethton Municipal Airport

4. EXTRA CREDIT - (2 POINT2) - NO HELP - NO PARTIAL CREDIT

Create a table with the names of the airports with the most

winds (wind_speed > 30). The table must contain only the airport

name (airports$name) and no duplicate rows

q4 <- weather %>%
  filter(wind_speed > 30) %>%
  left_join(airports, by = c("origin" = "faa")) %>%
  select(name) %>%
  distinct()

knitr::kable(head(q4))
name
Newark Liberty Intl
John F Kennedy Intl
La Guardia