Nations HW

library(tidyverse)
nations <- read_csv("nations.csv")
nations <- nations |>
  mutate(gdp = (gdp_percap * population) / 1000000000000)
four_nations <- nations |>
  filter(iso2c == "AE" | iso2c == "IR" | iso2c == "SA" | iso2c == "TR")
ggplot(four_nations, aes(x = year, y = gdp, color = country)) +
  geom_line(size = 0.925) +
  geom_point(size = 2) +
  labs(x = "Year",
       y = "GDP (Trillions of $)",
       title = "GDP of Middle Eastern Powers (1990-2015)",
       color = "Country") +
  scale_color_brewer(palette = "Set1") +
  theme_minimal()
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.

regions <- nations |>
  group_by(region, year) |>
  summarise(GDP = sum(gdp, na.rm = TRUE))
ggplot(regions, aes(x = year, y = GDP, fill = region)) +
  geom_area(color = "white", size = 0.35) +
  scale_fill_brewer(palette = "Set2") +
  labs(x = "Year",
       y = "GDP (Trillions of $)",
       title = "GDP by Region",
       fill = "Region") +
  theme_minimal()