2  In Class Exercise 1

Published

October 19, 2022

##In class exercise here..

library(tidyverse)
library(nycflights13)

First of all we examine the data as how many rows and coloumns we have.

glimpse(planes)
Rows: 3,322
Columns: 9
$ tailnum      <chr> "N10156", "N102UW", "N103US", "N104UW", "N10575", "N105UW…
$ year         <int> 2004, 1998, 1999, 1999, 2002, 1999, 1999, 1999, 1999, 199…
$ type         <chr> "Fixed wing multi engine", "Fixed wing multi engine", "Fi…
$ manufacturer <chr> "EMBRAER", "AIRBUS INDUSTRIE", "AIRBUS INDUSTRIE", "AIRBU…
$ model        <chr> "EMB-145XR", "A320-214", "A320-214", "A320-214", "EMB-145…
$ engines      <int> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, …
$ seats        <int> 55, 182, 182, 182, 55, 182, 182, 182, 182, 182, 55, 55, 5…
$ speed        <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ engine       <chr> "Turbo-fan", "Turbo-fan", "Turbo-fan", "Turbo-fan", "Turb…

##In “plane” dataset, there is a information about construction information and planes information.

##calculate seats in Embraer by count of planes.

planes %>% 
  filter(manufacturer == "EMBRAER") %>% 
  group_by(seats) %>% 
  summarise(planes_counts = n()) %>% 
  arrange(desc(planes_counts))
# A tibble: 2 × 2
  seats planes_counts
  <int>         <int>
1    55           219
2    20            80

##calculate number of planes according to their manufacturer.

planes %>% 
  group_by(manufacturer) %>% 
  summarise(count=n()) %>% 
  arrange(manufacturer) %>% 
  print(n=35)
# A tibble: 35 × 2
   manufacturer                  count
   <chr>                         <int>
 1 AGUSTA SPA                        1
 2 AIRBUS                          336
 3 AIRBUS INDUSTRIE                400
 4 AMERICAN AIRCRAFT INC             2
 5 AVIAT AIRCRAFT INC                1
 6 AVIONS MARCEL DASSAULT            1
 7 BARKER JACK L                     1
 8 BEECH                             2
 9 BELL                              2
10 BOEING                         1630
11 BOMBARDIER INC                  368
12 CANADAIR                          9
13 CANADAIR LTD                      1
14 CESSNA                            9
15 CIRRUS DESIGN CORP                1
16 DEHAVILLAND                       1
17 DOUGLAS                           1
18 EMBRAER                         299
19 FRIEDEMANN JON                    1
20 GULFSTREAM AEROSPACE              2
21 HURLEY JAMES LARRY                1
22 JOHN G HESS                       1
23 KILDALL GARY                      1
24 LAMBERT RICHARD                   1
25 LEARJET INC                       1
26 LEBLANC GLENN T                   1
27 MARZ BARRY                        1
28 MCDONNELL DOUGLAS               120
29 MCDONNELL DOUGLAS AIRCRAFT CO   103
30 MCDONNELL DOUGLAS CORPORATION    14
31 PAIR MIKE E                       1
32 PIPER                             5
33 ROBINSON HELICOPTER CO            1
34 SIKORSKY                          1
35 STEWART MACO                      2