#REVIEW OF GLOBAL AIRPORT DATA BASED ON # OF SEATS THAT FLY THROUGH EACH INTERNATIONAL AIRPORT:

#setup wd & download file
setwd("~/NYU/classes/2. R/Assignments/challenge #3")
library(readr)
airports <- read_csv("Airports geospatial data.csv")
## Rows: 2173 Columns: 6
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (3): Orig, Name, Country Name
## dbl (3): TotalSeats, Airport1Latitude, Airport1Longitude
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(airports)
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
## 
##     col_factor

Let’s first get a high level understanding of the data through the following questions:

How many total airports are there in the world with international travel?

#how many total airports are there in the world with international travel?
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
paste("There are", comma(as.numeric(count(airports))),"total international airports as of 2019.")
## [1] "There are 2,173 total international airports as of 2019."
#the World Bank data includes total number of seats on every plane that flew through the airport in 2019, how many seats were there total?
paste ("There were", comma(round(sum(airports$TotalSeats),0)), "seats in 2019.")
## [1] "There were 2,417,985,669 seats in 2019."
#how many countries are there with at least 1 international airport?
countries = unique(airports$`Country Name`)
paste("As of 2019 there are", length(countries), "countries with at least 1 international airport.")
## [1] "As of 2019 there are 224 countries with at least 1 international airport."
#summarize by country outlining the total number of seats in each country
by_country <- group_by(airports, `Country Name`, Name)
summarise(by_country, TotalSeats = mean(TotalSeats, na.rm=TRUE))
## `summarise()` has grouped output by 'Country Name'. You can override using the `.groups` argument.
## # A tibble: 2,171 x 3
## # Groups:   Country Name [224]
##    `Country Name` Name                   TotalSeats
##    <chr>          <chr>                       <dbl>
##  1 Afghanistan    Bagram Airport             18017.
##  2 Afghanistan    Camp Bastion               14468.
##  3 Afghanistan    Herat                      22042.
##  4 Afghanistan    Jalalabad                   6344.
##  5 Afghanistan    Kabul International      1016197.
##  6 Afghanistan    Kandahar International     39924.
##  7 Afghanistan    Mazar-e-Sharif             58327.
##  8 Albania        Rinas                    2063323.
##  9 Algeria        AbouBakr Belkaid           32541.
## 10 Algeria        Aguenar                     1088.
## # ... with 2,161 more rows

How many US Airports have more than 10M seats?

#How many US Airports have more than 10M seats?

#filtering only the USA data 
usa <- filter(airports, `Country Name` == "United States")
usa = as.data.frame(usa)

#sorting the USA data 
usa[with(usa, order(-TotalSeats)), ]
##     Orig                                            Name   TotalSeats
## 148  JFK                             John F Kennedy Intl 24715743.980
## 154  LAX                                Los Angeles Intl 17998723.040
## 181  MIA                             Miami International 15930768.460
## 16   ATL                          Hartsfield-Jackson Int 11226868.000
## 97   EWR                             Newark Liberty Intl 11095742.750
## 256  SFO                              San Francisco Intl  9998319.506
## 210  ORD                            O'Hare International  9962225.616
## 136  IAH                    George Bush Intercontinental  9391946.487
## 77   DFW                            Dallas/Ft Worth Intl  7978625.879
## 105  FLL                              Ft Lauderdale Intl  6461105.287
## 135  IAD                            Dulles International  6062794.262
## 37   BOS                             Logan International  5785183.285
## 172  MCO                                    Orlando Intl  4707358.201
## 254  SEA                             Seattle-Tacoma Intl  4176431.378
## 82   DTW                       Metropolitan Wayne County  3870192.270
## 217  PHL                               Philadelphia Intl  3585245.524
## 128  HNL                                   Honolulu Intl  3473579.781
## 195  MSP                       Minneapolis International  3465706.720
## 59   CLT         Charlotte-Douglas International Airport  3038130.613
## 76   DEN                            Denver International  2574750.927
## 153  LAS                                   Mccarran Intl  2446949.092
## 126  GUM        Antonio B. Won Pat International Airport  2110270.659
## 160  LGA                                      La Guardia  1677178.643
## 218  PHX                                 Sky Harbor Intl  1594630.660
## 45   BWI                             Baltimore/Wash Intl  1084255.256
## 263  SLC                             Salt Lake City Intl  1049183.954
## 246  SAN                 San Diego International Airport   811523.237
## 280  TPA                             Tampa International   802826.906
## 261  SJC                              San Jose Municipal   745042.018
## 131  HOU                                 William P Hobby   726011.482
## 262  SJU                            Luis Munoz Marin Int   719109.013
## 174  MDW                    Chicago Midway International   613552.800
## 214  PDX                                   Portland Intl   607295.948
## 270  SPN                            Saipan International   553098.784
## 204  OAK                              Metro Oakland Intl   491019.893
## 234  RDU                    Raleigh-Durham International   425097.631
## 18   AUS          Austin-Bergstrom International Airport   408476.243
## 247  SAT                                San Antonio Intl   333593.337
## 228  PSP                               Palm Springs Muni   274764.196
## 70   CVG                 Northern Kentucky International   269720.584
## 75   DCA                          Ronald Reagan National   262306.821
## 205  OGG                                         Kahului   249862.445
## 265  SMF                        Sacramento International   246040.739
## 272  STL                           Lambert International   240867.137
## 245  RSW                 Southwest Florida International   239718.892
## 35   BNA                         Nashville International   230077.967
## 196  MSY                                New Orleans Intl   186089.351
## 209  ONT                                    Ontario Intl   181444.375
## 23   BDL                                    Bradley Intl   176405.096
## 151  KOA                                         Keahole   159666.717
## 101  FAT                   Fresno Yosemite International   156906.596
## 221  PIT                          Pittsburgh Internation   147235.340
## 57   CLE                                    Hopkins Intl   143144.988
## 267  SNA                              John Wayne Airport   141641.437
## 140  IND                               Indianapolis Intl   141602.440
## 60   CMH       John Glenn Columbus International Airport   132273.491
## 255  SFB                           Sanford International   130514.293
## 276  SWF                  Newburgh Stewart International   110682.152
## 213  PBI                                 Palm Beach Intl    92821.526
## 123  GSP                        Greenville International    90143.732
## 170  MCI                                Kansas City Intl    89012.819
## 273  STT                               Metropolitan Area    72066.456
## 12   ANC                                Ted Stevens Intl    55986.693
## 28   BHM                     Shuttlesworth International    50427.454
## 183  MKE                           General Mitchell Intl    49695.177
## 240  RNO                          Reno/Tahoe Internation    44538.907
## 43   BUF                   Buffalo Niagara International    44135.938
## 207  OMA                                 Eppley Airfield    43381.996
## 229  PVD                            T.F. Green State Apt    42732.046
## 175  MEM                                    Memphis Intl    35599.928
## 162  LIH                                           Lihue    35240.289
## 21   AZA                            Mesa Gateway Airport    30673.307
## 73   DAL                               Dallas Love Field    29551.060
## 271  SRQ                Sarasota-Bradenton International    28597.800
## 225  PPG                                  Pago Pago Intl    22392.944
## 231  RAP                             Rapid City Regional    21660.667
## 164  LKE                                  Lake Union Spb    20633.746
## 30   BIL                     Logan International Airport    19203.856
## 177  MFE                            Miller International    18865.882
## 211  ORF                                    Norfolk Intl    16517.396
## 220  PIE                          St.Pete-Clearwater Int    16326.744
## 53   CHS                    Charleston International/AFB    15754.788
## 110  FSM                             Fort Smith Regional    14298.900
## 2    ABQ                           International Sunport    14129.913
## 130  HOB                             Lea County Regional    12999.000
## 248  SAV                                Hilton Head Intl    12791.016
## 274  STX                                Henry E. Rohlsen    12587.365
## 147  JAX                               Jacksonville Intl    11582.109
## 81   DSM                        Des Moines International    10139.220
## 74   DAY               Dayton James M. Cox International     9857.575
## 235  RFD                  Chicago Rockford International     9567.264
## 119  GRK                             Regional/R.Gray AAF     9029.972
## 159  LFT                              Lafayette Regional     8930.313
## 142  ISN                              Sloulin Field Intl     8882.650
## 56   CIR                                   Cairo Airport     8787.324
## 139  ILM                        Wilmington International     8319.360
## 111  FWA                        Fort Wayne International     7582.750
## 198  MYR                      Myrtle Beach International     6958.798
## 13   APF                                Naples Municipal     6932.800
## 114  GFK                                Grand Forks Intl     6932.800
## 242  ROC                 Greater Rochester International     6737.815
## 10   ALB                            Albany International     6716.150
## 29   BIF                                       Biggs Aaf     6482.168
## 182  MIB                            Minot Air Force Base     6482.168
## 199  NGU                     Norfolk NS (Chambers Field)     6482.168
## 264  SLN                                 Salina Regional     6482.168
## 42   BTV                Burlington International Airport     6191.857
## 116  GNV                   J R Alison Regional Municipal     6074.866
## 36   BOI                Boise Air Terminal (Gowen Field)     5424.916
## 224  PNS                         Pensacola International     5416.250
## 282  TUL                             Tulsa International     5377.253
## 32   BKG                                 Branson Airport     5303.592
## 118  GRB                            Austin-Straubel Intl     5221.265
## 236  RIC                          Richmond International     5173.602
## 184  MLB                         Melbourne International     5130.272
## 257  SGF                        Springfield Branson Natl     4961.285
## 7    AEX                         Alexandria Intl Airport     4766.300
## 102  FAY                          Regional (Grannis Fld)     4657.975
## 193  MSN              DCRA, Dane County Regional Airport     4493.321
## 279  TOL                                  Toledo Express     4419.660
## 190  MPB                                       Miami Spb     4367.664
## 189  MOT                             Minot International     4268.005
## 215  PFN                                      Bay County     4246.340
## 173  MDT                Harrisburg International Airport     4155.347
## 250  SBN                        South Bend International     4116.350
## 8    AGS                           Regional (Bush Field)     3899.700
## 5    ACY                              Atlantic City Intl     3847.704
## 137  ICT                            Dwight D. Eisenhower     3605.056
## 55   CID                        The Eastern Iowa Airport     3483.732
## 291  YUM                              Yuma International     3466.400
## 121  GRR            Gerald R. Ford International Airport     3345.076
## 200  NIP                              NAS (Towers Field)     3336.410
## 197  MTJ                               Montrose Regional     3327.744
## 85   EDF                        Elmendorf Air Force Base     3241.084
## 158  LEX                                      Blue Grass     3171.756
## 167  LSE                              La Crosse Regional     3033.100
## 289  VQS                             A. Rivera Rodriguez     3033.100
## 87   EIL                          Eielson Air Force Base     3007.102
## 230  PWM                            Portland Intl Jetprt     2989.770
## 290  XNA             Northwest Arkansas Regional Airport     2989.770
## 122  GSO                             Piedmont Triad Intl     2924.775
## 232  RDD                               Redding Municipal     2859.780
## 46   BZN               Yellowstone International Airport     2825.116
## 61   CMI                          University of Illinois     2599.800
## 96   EWN               Coastal Carolina Regional Airport     2599.800
## 165  LNK                                         Lincoln     2547.804
## 239  RNG                                         Rangely     2547.804
## 277  SYR                              Clarence E Hancock     2521.806
## 249  SBA                              Santa Barbara Muni     2504.474
## 201  NPT                                   State Airport     2495.808
## 72   DAB                     Daytona Beach International     2469.810
## 268  SPB                            Charlotte Amalie SPB     2469.810
## 38   BQN                                Rafael Hernandez     2443.812
## 26   BGM                              Greater Binghamton     2426.480
## 47   CAE                   Columbia Metropolitan Airport     2318.155
## 134  HSV               International-Carl T. Jones Field     2300.823
## 67   CRP                             Corpus Christi Intl     2274.825
## 146  JAN                   Medgar W. Evers International     2274.825
## 287  UAM                         Andersen Air Force Base     2157.834
## 125  GUC                                 Gunnison County     2123.170
## 187  MOB                                 Mobile Regional     2071.174
## 208  OME                                            Nome     2066.841
## 253  SDF                  International-Standiford Field     1993.180
## 260  SIG                            F.L. Ribas Dominicci     1975.848
## 52   CHP                              Circle Hot Springs     1967.182
## 157  LCK     Columbus Rickenbacker International Airport     1958.516
## 216  PHF         Newport News/Williamsburg International     1906.520
## 113  GEG                   Spokane International Airport     1880.522
## 188  MOD                               Modesto Municipal     1819.860
## 39   BRD                 Brainerd Lakes Regional Airport     1733.200
## 104  FLG                               Flagstaff Pulliam     1733.200
## 178  MFR                               Rogue Valley Intl     1698.536
## 66   CPR                                          Casper     1668.205
## 83   DWN                  Oklahoma City Downtown Airpark     1646.540
## 192  MRY                       Monterey Regional Airport     1646.540
## 54   CIC                                      Chico Muni     1559.880
## 33   BKL                                 Burke Lakefront     1551.214
## 202  NTD                                             NAS     1551.214
## 68   CRW                                          Yeager     1516.550
## 107  FOE                                    Forbes Field     1507.884
## 99   FAI                                  Fairbanks Intl     1490.552
## 6    ADW                              Joint Base Andrews     1438.556
## 69   CSL                                  O'Sullivan AHP     1429.890
## 168  MAF                             Midland-Odessa Regl     1421.224
## 286  TYS                                    McGhee Tyson     1408.225
## 243  ROP                              Rota International     1360.562
## 11   AMA                               Rick Husband Intl     1299.900
## 27   BGR                            Bangor International     1299.900
## 44   BUR                               Hollywood-Burbank     1299.900
## 191  MQT                    Sawyer International Airport     1299.900
## 269  SPI                               A.Lincoln Capital     1299.900
## 227  PSE                                       Mercedita     1234.905
## 15   ASE                                   Pitkin County     1213.240
## 120  GRN                                Gordon Municipal     1213.240
## 180  MHT              Manchester Boston Regional Airport     1191.575
## 275  SVN                                      Hunter Aaf     1165.577
## 20   AVP     Wilkes-Barre/Scranton International Airport     1161.244
## 212  PAE                                Snohomish County     1100.582
## 144  ITH                               Tompkins Regional     1083.250
## 186  MLU                                 Monroe Regional     1083.250
## 283  TUS                            Tucson International     1083.250
## 86   EGE                               Eagle County Regl     1039.920
## 145  JAC                                    Jackson Hole     1022.588
## 288  VPS                  Destin-Ft Walton Beach Airport      974.925
## 285  TYR                                    Pounds Field      966.259
## 89   ELP                                    El Paso Intl      957.593
## 141  INT                                  Smith-Reynolds      957.593
## 278  TLH                       Tallahassee International      953.260
## 88   ELM                            Celmira/Corning Regl      901.264
## 62   CMX                        Houghton County Memorial      866.600
## 71   CWA                               Central Wisconsin      866.600
## 80   DRT                                    Del Rio Intl      866.600
## 143  ISP                           Long Island MacArthur      866.600
## 156  LCH                           Lake Charles Regional      866.600
## 259  SHV                             Shreveport Regional      866.600
## 133  HRL                            Valley International      823.270
## 237  RIV                            March Air Force Base      810.271
## 9    AKN                                     King Salmon      805.938
## 92   EUG                              Mahlon Sweet Field      779.940
## 161  LGB                            Long Beach Municipal      775.607
## 58   CLL                                Easterwood Field      758.275
## 14   APN                          Alpena County Regional      736.610
## 284  TVC                                  Cherry Capital      736.610
## 223  PML                                     Port Moller      727.944
## 176  MER                           Castle Air Force Base      701.946
## 49   CCB                                           Cable      693.280
## 63   COD                            Yellowstone Regional      693.280
## 4    ACV                                          Arcata      658.616
## 34   BMI               Central Illinois Regional Airport      658.616
## 251  SBP                             San Luis Obispo Cty      658.616
## 3    ACK                              Nantucket Memorial      649.950
## 17   ATW                  Appleton International Airport      649.950
## 84   ECP Northwest Florida Beaches International Airport      649.950
## 106  FNT                            Bishop International      649.950
## 179  MGM                         Regional-Dannelly Field      649.950
## 90   ERI                              Erie International      641.284
## 132  HPN                              Westchester County      632.618
## 79   DRO                                        La Plata      606.620
## 194  MSO                          Missoula International      606.620
## 22   AZO    Kalamazoo/Battle Creek International Airport      597.954
## 185  MLI                         Quad City International      589.288
## 64   COS                                       Municipal      584.955
## 149  JNU                            Juneau International      584.955
## 91   ESD                                    Orcas Island      554.624
## 108  FRD                           Friday Harbor Airport      554.624
## 163  LIT                        B. & H. Clinton National      545.958
## 155  LBB                              Preston Smith Intl      541.625
## 166  LRD                                     Laredo Intl      541.625
## 238  RKS                               Sweetwater County      519.960
## 25   BFL                                   Meadows Field      493.962
## 51   CHO                                       Albemarle      476.630
## 1    ABE             Lehigh Valley International Airport      433.300
## 50   CHA                Chattanooga Metropolitan Airport      433.300
## 78   DLH                            Duluth International      433.300
## 117  GPT           Gulfport Biloxi International Airport      433.300
## 124  GTF                                Great Falls Intl      433.300
## 127  HDN                                    Yampa Valley      433.300
## 222  PLN                         Regional (Emmet County)      433.300
## 233  RDM                                   Roberts Field      433.300
## 244  RST                         Rochester International      433.300
## 252  SCE                                   State College      433.300
## 93   EVA                          Ben Bruce Mem. Airpark      411.635
## 24   BFI          Boeing Field-King County International      389.970
## 100  FAR                            Hector International      329.308
## 103  FCA                               Glacier Park Intl      329.308
## 115  GJT                                    Walker Field      329.308
## 152  LAN                    Capital Region International      329.308
## 169  MBS                               MBS International      329.308
## 241  ROA                          Regional (Woodrum Fld)      329.308
## 281  TRI                           Tri-Cities Rgnl TN/VA      329.308
## 109  FSD                                  Joe Foss Field      324.975
## 138  IDA                                        Regional      324.975
## 129  HNS                                          Haines      303.310
## 226  PSC                                      Tri-Cities      303.310
## 258  SGY                                         Skagway      303.310
## 150  KEH                          Kenmore Air Harbor SPB      298.977
## 19   AVL                              Asheville Regional      285.978
## 98   EYW                                   Key West Intl      285.978
## 112  GCC                                 Campbell County      259.980
## 266  SMX                              Santa Maria Public      259.980
## 40   BRO                            South Padre Isl Intl      216.650
## 41   BTR                        Metropolitan -Ryan Field      216.650
## 48   CAK                                 Canton Regional      216.650
## 65   COU                               Columbia Regional      216.650
## 94   EVV                             Evansville Regional      216.650
## 203  OAJ                                  Albert J Ellis      216.650
## 95   EWD                            Wildman Lake Airport      181.986
## 171  MCN                             Middle Georgia Rgnl      173.320
## 31   BIS                              Bismarck Municipal      108.325
## 206  OKC                               Will Rogers World      108.325
## 219  PIA                   General Downing International      108.325
##      Country Name Airport1Latitude Airport1Longitude
## 148 United States          40.6386          -73.7769
## 154 United States          33.9422         -118.4072
## 181 United States          25.7925          -80.2861
## 16  United States          33.6408          -84.4272
## 97  United States          40.6958          -74.1717
## 256 United States          37.6194         -122.3728
## 210 United States          41.9781          -87.9061
## 136 United States          29.9833          -95.3400
## 77  United States          32.8964          -97.0411
## 105 United States          26.0742          -80.1517
## 135 United States          38.9417          -77.4575
## 37  United States          42.3636          -71.0061
## 172 United States          28.4317          -81.3247
## 254 United States          47.4492         -122.3081
## 82  United States          42.2167          -83.3444
## 217 United States          39.8681          -75.2486
## 128 United States          21.3219         -157.9253
## 195 United States          44.8861          -93.2178
## 59  United States          35.2192          -80.9358
## 76  United States          39.8583         -104.6669
## 153 United States          36.0797         -115.1589
## 126 United States          13.4817          144.7933
## 160 United States          40.7794          -73.8758
## 218 United States          33.4361         -112.0089
## 45  United States          39.1750          -76.6700
## 263 United States          40.7842         -111.9669
## 246 United States          32.7336         -117.1867
## 280 United States          27.9731          -82.5353
## 261 United States          37.3611         -121.9256
## 131 United States          29.6450          -95.2786
## 262 United States          18.4414          -66.0022
## 174 United States          41.7850          -87.7519
## 214 United States          45.5892         -122.5950
## 270 United States          15.1203          145.7303
## 204 United States          37.7236         -122.2156
## 234 United States          35.8753          -78.7819
## 18  United States          30.1945          -97.6699
## 247 United States          29.5333          -98.4694
## 228 United States          33.8267         -116.5050
## 70  United States          39.0461          -84.6639
## 75  United States          38.8517          -77.0369
## 205 United States          20.9006         -156.4336
## 265 United States          38.6956         -121.5897
## 272 United States          38.7472          -90.3644
## 245 United States          26.5361          -81.7550
## 35  United States          36.1267          -86.6819
## 196 United States          29.9911          -90.2514
## 209 United States          34.0572         -117.6081
## 23  United States          41.9375          -72.6831
## 151 United States          19.6469         -156.0125
## 101 United States          36.7767         -119.7172
## 221 United States          40.4967          -80.2358
## 57  United States          41.4108          -81.8494
## 267 United States          33.6756         -117.8672
## 140 United States          39.7256          -86.2839
## 60  United States          39.9911          -82.8783
## 255 United States          28.7750          -81.2403
## 276 United States          41.5058          -74.0972
## 213 United States          26.6822          -80.0942
## 123 United States          34.8989          -82.2139
## 170 United States          39.2928          -94.7267
## 273 United States          18.3372          -64.9733
## 12  United States          61.1692         -149.9853
## 28  United States          33.5631          -86.7556
## 183 United States          42.9503          -87.8972
## 240 United States          39.4978         -119.7675
## 43  United States          42.9406          -78.7325
## 207 United States          41.3019          -95.8933
## 229 United States          41.7283          -71.4261
## 175 United States          35.0497          -89.9786
## 162 United States          21.9792         -159.3458
## 21  United States          33.3078         -111.6554
## 73  United States          32.8469          -96.8514
## 271 United States          27.3939          -82.5542
## 225 United States         -14.3344         -170.7097
## 231 United States          44.0453         -103.0569
## 164 United States          47.6167         -122.3333
## 30  United States          45.8069         -108.5428
## 177 United States          26.1769          -98.2397
## 211 United States          36.8958          -76.2014
## 220 United States          27.9167          -82.6833
## 53  United States          32.8992          -80.0389
## 110 United States          35.3361          -94.3700
## 2   United States          35.0417         -106.6064
## 130 United States          32.6886         -103.2169
## 248 United States          32.1275          -81.2025
## 274 United States          17.7039          -64.7989
## 147 United States          30.4847          -81.6878
## 81  United States          41.5339          -93.6567
## 74  United States          39.9011          -84.2200
## 235 United States          42.1972          -89.0925
## 119 United States          31.0647          -97.8275
## 159 United States          30.2047          -91.9875
## 142 United States          48.1761         -103.6361
## 56  United States          37.0000          -89.1833
## 139 United States          34.2669          -77.9039
## 111 United States          40.9783          -85.1881
## 198 United States          33.6792          -78.9297
## 13  United States          26.1528          -81.7753
## 114 United States          47.9519          -97.1786
## 242 United States          43.1214          -77.6708
## 10  United States          42.7458          -73.8053
## 29  United States          31.8494         -106.3794
## 182 United States          48.4156         -101.3572
## 199 United States          36.9372          -76.2906
## 264 United States          38.7908          -97.6525
## 42  United States          44.4728          -73.1531
## 116 United States          29.6897          -82.2758
## 36  United States          43.5653         -116.2250
## 224 United States          30.4725          -87.1883
## 282 United States          36.1978          -95.8897
## 32  United States          36.5317          -93.1997
## 118 United States          44.4881          -88.1306
## 236 United States          37.5061          -77.3225
## 184 United States          28.1025          -80.6431
## 257 United States          37.2400          -93.3850
## 7   United States          31.3274          -92.5486
## 102 United States          34.9914          -78.8803
## 193 United States          43.1419          -89.3369
## 279 United States          41.5908          -83.8008
## 190 United States          25.7475          -80.1735
## 189 United States          48.2594         -101.2808
## 215 United States          30.2125          -85.6819
## 173 United States          40.1931          -76.7622
## 250 United States          41.7047          -86.3167
## 8   United States          33.3692          -81.9644
## 5   United States          39.4567          -74.5778
## 137 United States          37.6500          -97.4328
## 55  United States          41.8844          -91.7061
## 291 United States          32.6542         -114.6069
## 121 United States          42.8811          -85.5242
## 200 United States          30.2342          -81.6753
## 197 United States          38.5006         -107.8947
## 85  United States          61.2524         -149.7980
## 158 United States          38.0397          -84.6022
## 167 United States          43.8767          -91.2561
## 289 United States          18.1333          -65.4906
## 87  United States          64.6650         -147.0969
## 230 United States          43.6444          -70.3036
## 290 United States          36.2817          -94.3067
## 122 United States          36.0919          -79.9428
## 232 United States          40.5083         -122.2922
## 46  United States          45.7803         -111.1594
## 61  United States          40.0397          -88.2797
## 96  United States          35.0736          -77.0425
## 165 United States          40.8508          -96.7589
## 239 United States          40.0947         -108.7606
## 277 United States          43.1106          -76.1025
## 249 United States          34.4278         -119.8394
## 201 United States          41.5308          -71.2825
## 72  United States          29.1825          -81.0528
## 268 United States          18.3369          -64.9683
## 38  United States          18.4958          -67.1300
## 26  United States          42.2014          -75.9692
## 47  United States          33.9364          -81.1158
## 134 United States          34.6428          -86.7756
## 67  United States          27.7700          -97.5008
## 146 United States          32.3097          -90.0758
## 287 United States          13.5818          144.9268
## 125 United States          38.5339         -106.9389
## 187 United States          30.6883          -88.2408
## 208 United States          64.5114         -165.4417
## 253 United States          38.1797          -85.7386
## 260 United States          18.4589          -66.1028
## 52  United States          65.4861         -144.6111
## 157 United States          39.8142          -82.9322
## 216 United States          37.1317          -76.4933
## 113 United States          47.6169         -117.5372
## 188 United States          37.6269         -120.9553
## 39  United States          46.3972          -94.1375
## 104 United States          35.1378         -111.6717
## 178 United States          42.3736         -122.8722
## 66  United States          42.9086         -106.4625
## 83  United States          35.4500          -97.5333
## 192 United States          36.5881         -121.8481
## 54  United States          39.7958         -121.8567
## 33  United States          41.5169          -81.6833
## 202 United States          34.1203         -119.1200
## 68  United States          38.3728          -81.5931
## 107 United States          38.9525          -95.6625
## 99  United States          64.8144         -147.8628
## 6   United States          38.8108          -76.8666
## 69  United States          35.2366         -120.6389
## 168 United States          31.9408         -102.2014
## 286 United States          35.8122          -83.9925
## 243 United States          14.1733          145.2389
## 11  United States          35.2272         -101.7219
## 27  United States          44.8078          -68.8278
## 44  United States          34.2000         -118.3578
## 191 United States          46.5342          -87.5617
## 269 United States          39.8442          -89.6789
## 227 United States          18.0097          -66.5614
## 15  United States          39.2242         -106.8689
## 120 United States          42.8000         -102.2000
## 180 United States          42.9383          -71.4389
## 275 United States          32.0100          -81.1458
## 20  United States          41.3392          -75.7258
## 212 United States          47.9083         -122.2814
## 144 United States          42.4903          -76.4581
## 186 United States          32.5111          -92.0389
## 283 United States          32.1161         -110.9406
## 86  United States          39.6436         -106.9139
## 145 United States          43.6067         -110.7369
## 288 United States          30.4833          -86.5253
## 285 United States          32.3547          -95.3989
## 89  United States          31.8067         -106.3772
## 141 United States          36.1353          -80.2256
## 278 United States          30.3997          -84.3519
## 88  United States          42.1608          -76.8953
## 62  United States          47.1678          -88.4864
## 71  United States          44.7822          -89.6592
## 80  United States          29.3333         -100.9783
## 143 United States          40.7967          -73.1008
## 156 United States          30.1311          -93.2256
## 259 United States          32.4469          -93.8286
## 133 United States          26.2281          -97.6522
## 237 United States          33.9833         -117.3667
## 9   United States          58.6786         -156.6494
## 92  United States          44.1208         -123.2175
## 161 United States          33.8175         -118.1511
## 58  United States          30.5894          -96.3644
## 14  United States          45.0817          -83.5558
## 284 United States          44.7400          -85.5858
## 223 United States          56.0056         -160.5583
## 176 United States          37.3795         -120.5671
## 49  United States          34.1116         -117.6866
## 63  United States          44.5158         -109.0275
## 4   United States          40.9792         -124.1075
## 34  United States          40.4819          -88.9275
## 251 United States          35.2367         -120.6392
## 3   United States          41.2567          -70.0597
## 17  United States          44.2578          -88.5200
## 84  United States          30.3578          -85.7989
## 106 United States          42.9667          -83.7417
## 179 United States          32.3000          -86.3911
## 90  United States          42.0800          -80.1786
## 132 United States          41.0689          -73.7078
## 79  United States          37.1500         -107.7511
## 194 United States          46.9156         -114.0875
## 22  United States          42.2364          -85.5536
## 185 United States          41.4489          -90.5050
## 64  United States          38.8089         -104.7092
## 149 United States          58.3556         -134.5747
## 91  United States          48.7083         -122.9125
## 108 United States          48.5264         -123.0239
## 163 United States          34.7292          -92.2344
## 155 United States          33.6622         -101.8228
## 166 United States          27.5447          -99.4611
## 238 United States          41.5964         -109.0658
## 25  United States          35.4300         -119.0522
## 51  United States          38.1414          -78.4531
## 1   United States          40.6547          -75.4383
## 50  United States          35.0364          -85.2036
## 78  United States          46.8425          -92.1903
## 117 United States          30.4061          -89.0703
## 124 United States          47.4856         -111.3669
## 127 United States          40.4817         -107.2200
## 222 United States          45.5708          -84.7928
## 233 United States          44.2544         -121.1514
## 244 United States          43.9103          -92.4964
## 252 United States          40.7708          -77.8814
## 93  United States          30.3500          -94.0667
## 24  United States          47.5289         -122.2994
## 100 United States          46.9156          -96.8147
## 103 United States          48.3128         -114.2511
## 115 United States          39.1186         -108.5139
## 152 United States          42.7792          -84.5883
## 169 United States          43.5317          -84.0817
## 241 United States          37.3247          -79.9764
## 281 United States          36.4761          -82.4064
## 109 United States          43.5789          -96.7408
## 138 United States          43.5161         -112.0647
## 129 United States          59.2458         -135.5189
## 226 United States          46.2639         -119.1147
## 258 United States          59.4606         -135.3156
## 150 United States          47.7383         -122.2681
## 19  United States          35.4350          -82.5411
## 98  United States          24.5556          -81.7597
## 112 United States          44.3514         -105.5250
## 266 United States          34.9050         -120.4578
## 40  United States          25.9064          -97.4256
## 41  United States          30.5317          -91.1506
## 48  United States          40.9139          -81.4417
## 65  United States          38.8136          -92.2192
## 94  United States          38.0367          -87.5325
## 203 United States          34.8303          -77.6117
## 95  United States          56.4564         -159.7622
## 171 United States          32.6929          -83.6492
## 31  United States          46.7789         -100.7525
## 206 United States          35.3931          -97.6006
## 219 United States          40.6614          -89.6872
#subsetting 
usa_ss = subset.data.frame(usa, usa$TotalSeats > 10000000)

usa_seats=as.data.frame(subset(usa_ss, select = -c(2,4,5,6)))

View(usa_seats)

paste("There are", count(usa_seats), "US Airports with over 10m seats")
## [1] "There are 5 US Airports with over 10m seats"

show this in a bar graph:

#To show this in a bar graph: 
library(ggplot2)
# Basic barplot
p<-ggplot(data=usa_seats, aes(x=Orig, y=TotalSeats)) +
  geom_bar(stat="identity")
print(p)