q1 <- flights %>%
filter(origin == 'LGA', dest == 'XNA') %>%
left_join(planes, by = 'tailnum') %>%
select(type, manufacturer) %>%
distinct()
head(q1)
## # A tibble: 5 × 2
## type manufacturer
## <chr> <chr>
## 1 <NA> <NA>
## 2 Fixed wing multi engine GULFSTREAM AEROSPACE
## 3 Fixed wing single engine CESSNA
## 4 Fixed wing multi engine CANADAIR LTD
## 5 Fixed wing multi engine BOMBARDIER INC
q2 <- flights %>%
inner_join(airlines, by = "carrier") %>% # Join using the 'carrier' column
select(flight, carrier, name)
head(q2)
## # A tibble: 6 × 3
## flight carrier name
## <int> <chr> <chr>
## 1 1545 UA United Air Lines Inc.
## 2 1714 UA United Air Lines Inc.
## 3 1141 AA American Airlines Inc.
## 4 725 B6 JetBlue Airways
## 5 461 DL Delta Air Lines Inc.
## 6 1696 UA United Air Lines Inc.
q3 <- anti_join(airports,
flights %>%
select(origin, dest) %>%
pivot_longer(cols = c(origin, dest), values_to = "faa") %>%
distinct(faa),
by = "faa")%>%
select(faa, name)
head(q3)
## # 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
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 %>%
filter(wind_speed > 30) %>% # Filter for high wind speeds
select(origin) %>% # Select origin (airport code) and wind speed
distinct() %>% # Remove duplicate rows
inner_join(airports, by = c("origin" = "faa")) %>% # Join with airports dataset
select(name) %>% # Select airport name and wind speed
distinct() # Remove duplicate rows
head(extra_credit)
## # A tibble: 3 × 1
## name
## <chr>
## 1 Newark Liberty Intl
## 2 John F Kennedy Intl
## 3 La Guardia