1. join + filter - Which airplanes fly LGA to XNA (1 POINT)
q1 <- inner_join(flights, planes, by = "tailnum") %>%
filter(origin == "LGA", dest == "XNA") %>%
select(tailnum, origin, dest)
q1
## # A tibble: 66 × 3
## tailnum origin dest
## <chr> <chr> <chr>
## 1 N711MQ LGA XNA
## 2 N711MQ LGA XNA
## 3 N711MQ LGA XNA
## 4 N711MQ LGA XNA
## 5 N711MQ LGA XNA
## 6 N737MQ LGA XNA
## 7 N737MQ LGA XNA
## 8 N711MQ LGA XNA
## 9 N711MQ LGA XNA
## 10 N840MQ LGA XNA
## # ℹ 56 more rows
2. join - Add the airline name to the flights table (1 POINT)
q2 <- left_join(flights, airlines, by = "carrier") %>%
select(carrier, name)
q2
## # A tibble: 336,776 × 2
## carrier name
## <chr> <chr>
## 1 UA United Air Lines Inc.
## 2 UA United Air Lines Inc.
## 3 AA American Airlines Inc.
## 4 B6 JetBlue Airways
## 5 DL Delta Air Lines Inc.
## 6 UA United Air Lines Inc.
## 7 B6 JetBlue Airways
## 8 EV ExpressJet Airlines Inc.
## 9 B6 JetBlue Airways
## 10 AA American Airlines Inc.
## # ℹ 336,766 more rows
3. join + select + distinct() - Which airports have no commercial
flights (1 POINT)
q3 <- airports %>%
anti_join(
flights %>%
select(origin, dest) %>%
pivot_longer(cols = c(origin, dest), values_to = "faa") %>%
distinct(faa),
by = "faa"
) %>%
select(faa, name)
q3
## # A tibble: 1,355 × 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
## 7 0G6 Williams County Airport
## 8 0G7 Finger Lakes Regional Airport
## 9 0P2 Shoestring Aviation Airfield
## 10 0S9 Jefferson County Intl
## # ℹ 1,345 more rows
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
extra <- airports %>%
inner_join(
weather %>%
filter(wind_speed > 30) %>%
select(origin) %>%
distinct(),
by = c("faa" = "origin")
) %>%
select(name) %>%
distinct()
extra
## # A tibble: 3 × 1
## name
## <chr>
## 1 Newark Liberty Intl
## 2 John F Kennedy Intl
## 3 La Guardia