R Markdown

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

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

q1
## # A tibble: 5 × 5
##   manufacturer         model       seats engines type                    
##   <chr>                <chr>       <int>   <int> <chr>                   
## 1 <NA>                 <NA>           NA      NA <NA>                    
## 2 GULFSTREAM AEROSPACE G1159B         22       2 Fixed wing multi engine 
## 3 CESSNA               172N            4       1 Fixed wing single engine
## 4 CANADAIR LTD         CF-5D           2       4 Fixed wing multi engine 
## 5 BOMBARDIER INC       CL-600-2C10    80       2 Fixed wing multi engine

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

q2 <- flights %>%
  left_join(airlines, by = "carrier") %>%
  select(flight, carrier, name, origin, dest, tailnum, everything())

q2
## # A tibble: 336,776 × 20
##    flight carrier name           origin dest  tailnum  year month   day dep_time
##     <int> <chr>   <chr>          <chr>  <chr> <chr>   <int> <int> <int>    <int>
##  1   1545 UA      United Air Li… EWR    IAH   N14228   2013     1     1      517
##  2   1714 UA      United Air Li… LGA    IAH   N24211   2013     1     1      533
##  3   1141 AA      American Airl… JFK    MIA   N619AA   2013     1     1      542
##  4    725 B6      JetBlue Airwa… JFK    BQN   N804JB   2013     1     1      544
##  5    461 DL      Delta Air Lin… LGA    ATL   N668DN   2013     1     1      554
##  6   1696 UA      United Air Li… EWR    ORD   N39463   2013     1     1      554
##  7    507 B6      JetBlue Airwa… EWR    FLL   N516JB   2013     1     1      555
##  8   5708 EV      ExpressJet Ai… LGA    IAD   N829AS   2013     1     1      557
##  9     79 B6      JetBlue Airwa… JFK    MCO   N593JB   2013     1     1      557
## 10    301 AA      American Airl… LGA    ORD   N3ALAA   2013     1     1      558
## # ℹ 336,766 more rows
## # ℹ 10 more variables: sched_dep_time <int>, dep_delay <dbl>, arr_time <int>,
## #   sched_arr_time <int>, arr_delay <dbl>, 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(faa, name, lat, lon, alt, tz, dst) %>%
  distinct()

q3
## # A tibble: 1,355 × 7
##    faa   name                             lat    lon   alt    tz dst  
##    <chr> <chr>                          <dbl>  <dbl> <dbl> <dbl> <chr>
##  1 04G   Lansdowne Airport               41.1  -80.6  1044    -5 A    
##  2 06A   Moton Field Municipal Airport   32.5  -85.7   264    -6 A    
##  3 06C   Schaumburg Regional             42.0  -88.1   801    -6 A    
##  4 06N   Randall Airport                 41.4  -74.4   523    -5 A    
##  5 09J   Jekyll Island Airport           31.1  -81.4    11    -5 A    
##  6 0A9   Elizabethton Municipal Airport  36.4  -82.2  1593    -5 A    
##  7 0G6   Williams County Airport         41.5  -84.5   730    -5 A    
##  8 0G7   Finger Lakes Regional Airport   42.9  -76.8   492    -5 A    
##  9 0P2   Shoestring Aviation Airfield    39.8  -76.6  1000    -5 U    
## 10 0S9   Jefferson County Intl           48.1 -123.    108    -8 A    
## # ℹ 1,345 more rows

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) %>%
  inner_join(airports, by = c("origin" = "faa")) %>%
  select(name) %>%
  distinct()

q4
## # A tibble: 3 × 1
##   name               
##   <chr>              
## 1 Newark Liberty Intl
## 2 John F Kennedy Intl
## 3 La Guardia