Nations Dataset Charts HW

Author

Bryan Argueta

# loads in a library and imports the data set
library(tidyverse)
library(RColorBrewer)
setwd("/Users/bryana/Documents/Data110/Datasets")
nations <- read_csv("nations.csv")

GDP Variable

nations_gdp <- nations |>
  mutate(gdp = gdp_percap * population / 10^12)

Chart One:

desired_countries <- nations_gdp |>
  filter(country %in% c("Honduras", "El Salvador", "Guatemala", "Nicaragua"))

I chose these specific countries because I am from Honduras and I wanted to see how it stacked up when compared to some of its neighborsin terms of GDP.

ggplot(desired_countries, aes(x = year, y = gdp, color = country)) +
  geom_point() + 
  geom_line() +
  scale_color_brewer(palette = "Set1") +
  labs(x = "Years", y = "GDP ($ trillion)", title = "Guatemala's Rise Over Neighboring Countries") +
  theme_minimal()

Overall, Guatemala’s GDP is significantly higher than the other three countries and it is growing at a much higher rate than them as well. This makes sense because Guatemala also has the highest population out of the four countries so they have a larger work force.

Chart Two:

summarized_nations <- nations_gdp |>
  group_by(region, year) |>
  summarise(sum_GDP = sum(gdp, na.rm = TRUE))
ggplot(summarized_nations, aes(x = year, y = sum_GDP, fill = region)) +
    geom_area(color = "white") +
    scale_fill_brewer(palette = "Set2") +
    labs(x = "Year", y = "GDP ($ trillions)", title = "GDP by World Bank Region") +
    theme_minimal()