2  Assignment 2

Published

October 21, 2022

If we want to see how many flights held by which manufacturers’ planes

nycflights13::planes
# A tibble: 3,322 × 9
   tailnum  year type                   manuf…¹ model engines seats speed engine
   <chr>   <int> <chr>                  <chr>   <chr>   <int> <int> <int> <chr> 
 1 N10156   2004 Fixed wing multi engi… EMBRAER EMB-…       2    55    NA Turbo…
 2 N102UW   1998 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
 3 N103US   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
 4 N104UW   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
 5 N10575   2002 Fixed wing multi engi… EMBRAER EMB-…       2    55    NA Turbo…
 6 N105UW   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
 7 N107US   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
 8 N108UW   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
 9 N109UW   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
10 N110UW   1999 Fixed wing multi engi… AIRBUS… A320…       2   182    NA Turbo…
# … with 3,312 more rows, and abbreviated variable name ¹​manufacturer
data <- planes %>% 
 group_by(manufacturer) %>% 
 summarise(count=n()) %>% 
 arrange(desc(count)) %>% 
 print(n=Inf)
# A tibble: 35 × 2
   manufacturer                  count
   <chr>                         <int>
 1 BOEING                         1630
 2 AIRBUS INDUSTRIE                400
 3 BOMBARDIER INC                  368
 4 AIRBUS                          336
 5 EMBRAER                         299
 6 MCDONNELL DOUGLAS               120
 7 MCDONNELL DOUGLAS AIRCRAFT CO   103
 8 MCDONNELL DOUGLAS CORPORATION    14
 9 CANADAIR                          9
10 CESSNA                            9
11 PIPER                             5
12 AMERICAN AIRCRAFT INC             2
13 BEECH                             2
14 BELL                              2
15 GULFSTREAM AEROSPACE              2
16 STEWART MACO                      2
17 AGUSTA SPA                        1
18 AVIAT AIRCRAFT INC                1
19 AVIONS MARCEL DASSAULT            1
20 BARKER JACK L                     1
21 CANADAIR LTD                      1
22 CIRRUS DESIGN CORP                1
23 DEHAVILLAND                       1
24 DOUGLAS                           1
25 FRIEDEMANN JON                    1
26 HURLEY JAMES LARRY                1
27 JOHN G HESS                       1
28 KILDALL GARY                      1
29 LAMBERT RICHARD                   1
30 LEARJET INC                       1
31 LEBLANC GLENN T                   1
32 MARZ BARRY                        1
33 PAIR MIKE E                       1
34 ROBINSON HELICOPTER CO            1
35 SIKORSKY                          1

If we want to see how many flights held by which manufacturers’ planes before year 2000 with more than 2 engines

data <- planes %>%
  filter(year<2000 & engines >2) %>%
  group_by(manufacturer) %>%
  summarize(count=n()) %>%
  arrange(desc(count)) %>%
  print(n=Inf)
# A tibble: 4 × 2
  manufacturer           count
  <chr>                  <int>
1 AVIONS MARCEL DASSAULT     1
2 BOEING                     1
3 CANADAIR LTD               1
4 DOUGLAS                    1