https://datacatalog.worldbank.org/search/dataset/0038117/Global-Airports

##1. import libraries

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.1
## ✔ readr   2.1.2     ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(dplyr)
library(ggplot2)

##2. import data

airport <- read_csv("airport_volume_airport_locations.csv")
## Rows: 2173 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Orig, Name, Country Name
## dbl (3): TotalSeats, Airport1Latitude, Airport1Longitude
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

##3. how many total seats does every country have?

totalseats <- data.frame(airport$`Country Name`, airport$TotalSeats)
options(scipen = 999)
countrytotalseats <- totalseats%>% group_by(airport..Country.Name.)%>%summarise_if(is.numeric, sum, names=TRUE)
countrytotalseats
## # A tibble: 224 × 2
##    airport..Country.Name. airport.TotalSeats
##    <chr>                               <dbl>
##  1 Afghanistan                      1175319.
##  2 Albania                          2063324.
##  3 Algeria                          5796918.
##  4 Angola                           1235517.
##  5 Anguilla                           28512.
##  6 Antigua and Barbuda               631488.
##  7 Argentina                        9154321.
##  8 Armenia                          1947468.
##  9 Aruba                            3390249.
## 10 Australia                       27365886.
## # … with 214 more rows

##4. create a histogram to show total seats in every countries’ airports

countrytotalseats01 <- ggplot(countrytotalseats, aes(x=airport..Country.Name., y=airport.TotalSeats)) + geom_bar(stat="identity",col="#8D25D1") + labs(title = "Total seats in every countries' airports", x = "Countries", y ="Count") 
countrytotalseats01