library(tidyverse)
library(nycflights13)
ch_18_solutions
Prerequisites:
18.3.4 Exercises:
Whether a flight has the tail number recorded in planes is highly correlated with the carrier, with nearly all flights from MQ (Envoy Air) not having a tail number recorded. Interesting to note that Envoy Air is a subsidiary of AA, the other carrier with a high proportion of tail numbers missing.
<- flights |> tailnum_not_in_plane distinct(tailnum) |> anti_join(planes, by = 'tailnum') |> pull() |> flights group_by(carrier) |> summarise( number_of_flights = n(), no_tail = sum(tailnum %in% tailnum_not_in_plane), perc_no_tail = round(no_tail / (number_of_flights) *100, 2) |> ) arrange(desc(number_of_flights)) ## # A tibble: 16 × 4 ## carrier number_of_flights no_tail perc_no_tail ## <chr> <int> <int> <dbl> ## 1 UA 58665 1693 2.89 ## 2 B6 54635 830 1.52 ## 3 EV 54173 0 0 ## 4 DL 48110 110 0.23 ## 5 AA 32729 22558 68.9 ## 6 MQ 26397 25397 96.2 ## 7 US 20536 699 3.4 ## 8 9E 18460 1044 5.66 ## 9 WN 12275 38 0.31 ## 10 VX 5162 0 0 ## 11 FL 3260 187 5.74 ## 12 AS 714 0 0 ## 13 F9 685 50 7.3 ## 14 YV 601 0 0 ## 15 HA 342 0 0 ## 16 OO 32 0 0