1. join + filter - Which airplanes fly LGA to XNA (1 POINT)
LGA_to_XNA <- flights %>%
inner_join(planes, join_by(tailnum)) %>%
filter(origin == "LGA", dest == "XNA") %>%
select(tailnum, manufacturer, model, flight, year.y, origin, dest) %>%
distinct()
head(LGA_to_XNA)
## # A tibble: 6 × 7
## tailnum manufacturer model flight year.y origin dest
## <chr> <chr> <chr> <int> <int> <chr> <chr>
## 1 N711MQ GULFSTREAM AEROSPACE G1159B 4525 1976 LGA XNA
## 2 N711MQ GULFSTREAM AEROSPACE G1159B 4534 1976 LGA XNA
## 3 N711MQ GULFSTREAM AEROSPACE G1159B 4413 1976 LGA XNA
## 4 N737MQ CESSNA 172N 4525 1977 LGA XNA
## 5 N737MQ CESSNA 172N 4413 1977 LGA XNA
## 6 N840MQ CANADAIR LTD CF-5D 4525 1974 LGA XNA
2. join - Add the airline name to the flights table (1 POINT)
flights_with_airline <- flights %>%
left_join(airlines, by = c("carrier" = "carrier"))
head(flights_with_airline)
## # A tibble: 6 × 20
## year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time
## <int> <int> <int> <int> <int> <dbl> <int> <int>
## 1 2013 1 1 517 515 2 830 819
## 2 2013 1 1 533 529 4 850 830
## 3 2013 1 1 542 540 2 923 850
## 4 2013 1 1 544 545 -1 1004 1022
## 5 2013 1 1 554 600 -6 812 837
## 6 2013 1 1 554 558 -4 740 728
## # ℹ 12 more variables: arr_delay <dbl>, carrier <chr>, flight <int>,
## # tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
## # hour <dbl>, minute <dbl>, time_hour <dttm>, name <chr>
3. join + select + distinct() - Which airports have no commercial
flights (1 POINT)
airports_no_flights <- airports %>%
anti_join(flights, by = c("faa" = "origin")) %>%
anti_join(flights, by = c("faa" = "dest")) %>%
select(faa, name) %>%
distinct()
head(airports_no_flights)
## # A tibble: 6 × 2
## faa name
## <chr> <chr>
## 1 04G Lansdowne Airport
## 2 06A Moton Field Municipal Airport
## 3 06C Schaumburg Regional
## 4 06N Randall Airport
## 5 09J Jekyll Island Airport
## 6 0A9 Elizabethton Municipal Airport