Nations Assignments

Load necessary packages.

library(readr) 
library(ggplot2) 
library(scales) 
## 
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
## 
##     col_factor
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

Load R Color Brewer.

library(RColorBrewer)

Load data set and add GDP by trillion dollars column.

nations <- read_csv("nations.csv") %>%
  mutate(gdp_tn = gdp_percap*population/1000000000000)
## Rows: 5275 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): iso2c, iso3c, country, region, income
## dbl (5): year, gdp_percap, population, birth_rate, neonat_mortal_rate
## 
## ℹ 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.

Abraham Accord GDP

The Abraham Accords are a joint statement between the State of Israel, the United Arab Emirates, and the United States, reached on August 13, 2020. Subsequently, the term was used to refer collectively to agreements between Israel and the United Arab Emirates and Bahrain. I decided to use Saudi Arabia instead of USA because it would be way too large of difference and Saudi Arabia was a negotiating party in this Peace in The Middle East Agreement.

So, I filter ARE which stands for United Arab Emirates, BHR which is Bahrain, ISR which is Israel, and SAU for Saudi Arabia.

Abraham_Accord <- nations %>%
    filter(iso3c == "ARE" | iso3c == "BHR" | iso3c == "ISR" | iso3c == "SAU") %>%
  arrange(year)

Plotting Chart Uno GDP for all parties.

Chart_1 <- ggplot(Abraham_Accord, aes(x = year, y = gdp_tn)) + xlab("Year") +
  ylab("GDP Per Trillion") +
  ggtitle("Abraham Accords GDP") +
  scale_color_brewer(palette = "Set1")

Output of plotting of the chart.

Chart_1 +
   geom_point(aes(color=country), size = 2)

You can see to no surprise that the princes of Saudi Arabia are the wealthiest of all four newly allied countries.

Chart 2: GDP by Region

Prepared data grouping by year & region and telling it to add up all the individual GDP by region.

# prepare data
regions <- nations %>%
  group_by(year,region) %>%
  summarize(gdp_tn = sum(gdp_tn, na.rm = TRUE)) %>%
  arrange(year,region)
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.

Defining the chart

Chart_2 <- ggplot(regions, aes(x = year, y = gdp_tn)) +
  xlab("Year") +
  ylab("GDP ($ Trillion)") +
  ggtitle("Regions GDP")+
  scale_color_brewer(palette = "Set2")

Plotting the chart

Chart_2 +
  geom_area(aes(colour=region, fill=region))

Each band represents the GDP of each region by year and they are stacked on top of each other. Europe & East Asia are about equal as present day although in the past Europe was the largest. Sub-Saharan Africa remains the lowest but in the past were tied with South Asia.