Nations Charts Assignment

Author

Latifah Traore

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

setwd("C:/Users/akais/OneDrive/Documents/nationsdataset")
nations <- read.csv("nations.csv")
nations <- nations %>%
  mutate(gdp = (gdp_percap * population) / 1e12)
filtered_nations <- nations %>%
  filter(country %in% c("Mali", "Ghana", "Gabon", "Cote d'Ivoire"))
ggplot(filtered_nations, aes(x = year, y = gdp, color = country)) +
  geom_point() +
  geom_line() +
  scale_color_brewer(palette = "Set1") +
  labs(title = "Ghana: West Africa's GDP Leader (1990–2015)",
       x = "Year",
       y = "GDP (Trillions $)") +
  theme_minimal()

region_gdp <- nations %>%
  group_by(region, year) %>%
  summarise(GDP = sum(gdp, na.rm = TRUE), .groups = 'drop')
ggplot(region_gdp, aes(x = year, y = GDP, fill = region)) +
  geom_area(color = "white") +
  scale_fill_brewer(palette = "Set2") +
  labs(title = "GDP by Region Over Time",
       x = "Year",
       y = "Total GDP (Trillions $)") +
  theme_minimal()