In this work, unlike the previous work I looked at the economic growths of the different regions around the world. What I expect to see is Europe being on top along with East Asia, and then South Asia and Africa being on the bottom. However, that may not be the case so let’s examine the data through an area graph.

First load in all the necessary packages. The essential ones this time will be “ggplot2” and “RColorBrewer”.

# install.packages("RColorBrewer")

library(ggplot2)
library(RColorBrewer)
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
library(readr)

Next we load in the dataset

setwd("/Users/justinpark/Desktop/Nations Dataset")

Then assign it to a specific variable

Since there is no variable for gdp of a country we need to calculate it. However, we will also need to divide the value by a trillion (1000000000000) otherwise the y axis values will be too large to handle.

nations <- read.csv("nations.csv") %>% 
  mutate(gdp_tn = gdp_percap*population/1000000000000)

# nations

Reorganizing the Dataset

In this dataset, we’ll be looking at the econmical growth not by country, but by region/continents. The regions without any data (NA) are removed through “na.rm = TRUE”.

by_region <- 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.
# by_region

Creating the Basic Graph

p3 <- ggplot() +
  geom_area(data = by_region, aes(x = year, y = gdp_tn, fill = region))

p3

In this area graph, there are no axes titles and some of the colors may be hard to tell apart. This should be changed using “scale_fill_brewer” next.

Creating the Final Graph

p4 <- ggplot() +
  geom_area(data = by_region, aes(x = year, y = gdp_tn, fill =  region)) +
  scale_fill_brewer(name = "Regions", palette = "Set2") +
  ggtitle("Economic Growth Over the Years by Region") +
  theme(plot.title = element_text(hjust = 1.5)) +
  labs(
    x = "Year",
    y = "GDP (in trillion $)")

p4

Overall

This graph is very similar to the plot chart with the top 4 countries (plus South Korea). However, this displays an area graph. Its goal is to show the development of the quantitative values over time unlike the line graph from before.

Much of the trends in this graph are nothing but expected. The East Asian & Pacific region display the highest GDP over the years as countries such as China, Japan, and South Korea likely make up most of this. Europe & Central Asia is also expected to be near the top as many of the countries in Europe are major countries in the world economics. These include countries such as Germany, England, Spain, and France. However, North America is a surprise to me. Even with the inclusion of the USA, it is still not enough to put the entire region any where near the top of the graph. It even falls under the South Asian region where a lot of third world countries exist. And lastly, Sub-Saharan Africa is also not a surprise. Ultimately, much of the displayed data on this graph was not much a surprise, besides North America. Similar to the graph of countries, this only conveys that countries that were ahead to begin with will likely stay ahead even in the future.