library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(RColorBrewer)
library(ggplot2)
library(dplyr)
setwd(("/Users/janithrithilakasiri/Downloads"))
nations <- read_csv("nations.csv")
## 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.
gdp_1 <- nations %>%
mutate(gdp = gdp_percap * population / 1e12)
gdp_tn_asia <- gdp_1 %>%
filter(country == "Sri Lanka" | country =="India"| country== "Pakistan"| country == "Nepal")
dot_plot <- gdp_tn_asia |> ggplot() +
geom_point(aes(x = year, y = gdp, color = country)) + scale_color_brewer(palette = "Set1") +
geom_line(aes(x = year, y = gdp, color = country)) +
labs(title = "South Asian Economy",
x = "Year",
y = "Gross Domestic Product ($ Trillion)",
color = "Country") +
theme_classic(base_size = 12) +
theme(legend.position = c(0.2, 0.7))
dot_plot
Since 1993, India’s Gross Domestic Product grew at a faster rate than the other countries listed. Between 1990 - 2005 other countries were mostly at the same rate but in 2006, we can see a little bit of a growth in Pakistan. However, Sri Lanka and Nepal rate of growths remained similar from 1990 - 2005. We can see a little bit of a growth from Sri Lanka in 2008 (That’s when our Sinhala and Tamil war ended in the country).I could say India had the most growth rate in South Asia between 1990 - 2015.
region_year <- gdp_1 |>
group_by(region, year) |>
summarise(gdp = sum(gdp, na.rm = TRUE))
## `summarise()` has grouped output by 'region'. You can override using the
## `.groups` argument.
reigon_y_p <- region_year |>
ggplot() +
geom_line(aes(x = year, y = gdp)) +
geom_area(aes(x = year, y = gdp, fill = region), color = "black") +
scale_fill_brewer(palette = "PRGn") +
labs(title = "Gross Domestic Prodct by World Bank Region",
x = "Year",
y = "Gross Domestic Product in Trillion",
color = "Region") +
theme_dark(base_size = 10) +
theme(plot.title = element_text(hjust = 0.9))
reigon_y_p
Sub - Saharan Africa & South Asia were the regions that had the
lowest gdp since 1993. East Asia & pacific , Europe & Central
Asia had the highest gdp from 1995 - 2015. We could also see that North
america and Europe & Central Asia has a little bit of a similar
growth until around 2005. I also decided to make a little bit of a
change and I chose the PRGn color palette instead of the Set2. I also
chose to do the outline from black instead of the white color because it
highlights the regions better in the graph.
dot_plot_ry <- region_year |>
ggplot(text = paste("Region:", region)) +
geom_line(aes(x = year, y = gdp)) +
geom_area(aes(x = year, y = gdp, fill = region), colour = "white") +
scale_fill_brewer(palette = "Set2") +
labs(title = "Gross Domestic Product by World Bank Region",
x = "Year",
y = "GDP in Trillion)",
color = "Region") +
theme_dark(base_size = 09) +
theme(plot.title = element_text(hjust = 0.10))
dot_plot_ry