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") %>%
inner_join(planes, by = "tailnum") %>%
select(origin, dest, tailnum, model, manufacturer)
q1
## # A tibble: 66 × 5
## origin dest tailnum model manufacturer
## <chr> <chr> <chr> <chr> <chr>
## 1 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 2 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 3 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 4 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 5 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 6 LGA XNA N737MQ 172N CESSNA
## 7 LGA XNA N737MQ 172N CESSNA
## 8 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 9 LGA XNA N711MQ G1159B GULFSTREAM AEROSPACE
## 10 LGA XNA N840MQ CF-5D CANADAIR LTD
## # ℹ 56 more rows
2. join - Add the airline name to the flights table (1 POINT)
q2 <- airlines %>%
inner_join(flights, by = "carrier")
q2
## # A tibble: 336,776 × 20
## carrier name year month day dep_time sched_dep_time dep_delay arr_time
## <chr> <chr> <int> <int> <int> <int> <int> <dbl> <int>
## 1 9E Endeavo… 2013 1 1 810 810 0 1048
## 2 9E Endeavo… 2013 1 1 1451 1500 -9 1634
## 3 9E Endeavo… 2013 1 1 1452 1455 -3 1637
## 4 9E Endeavo… 2013 1 1 1454 1500 -6 1635
## 5 9E Endeavo… 2013 1 1 1507 1515 -8 1651
## 6 9E Endeavo… 2013 1 1 1530 1530 0 1650
## 7 9E Endeavo… 2013 1 1 1546 1540 6 1753
## 8 9E Endeavo… 2013 1 1 1550 1550 0 1844
## 9 9E Endeavo… 2013 1 1 1552 1600 -8 1749
## 10 9E Endeavo… 2013 1 1 1554 1600 -6 1701
## # ℹ 336,766 more rows
## # ℹ 11 more variables: sched_arr_time <int>, arr_delay <dbl>, flight <int>,
## # tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
## # hour <dbl>, minute <dbl>, time_hour <dttm>
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(name) %>%
distinct()
q3
## # A tibble: 1,337 × 1
## name
## <chr>
## 1 Lansdowne Airport
## 2 Moton Field Municipal Airport
## 3 Schaumburg Regional
## 4 Randall Airport
## 5 Jekyll Island Airport
## 6 Elizabethton Municipal Airport
## 7 Williams County Airport
## 8 Finger Lakes Regional Airport
## 9 Shoestring Aviation Airfield
## 10 Jefferson County Intl
## # ℹ 1,327 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_credit <- weather %>%
inner_join(airports, by = c("origin" = "faa")) %>%
filter(wind_speed>30) %>%
select(name) %>%
distinct()
extra_credit
## # A tibble: 3 × 1
## name
## <chr>
## 1 Newark Liberty Intl
## 2 John F Kennedy Intl
## 3 La Guardia