hw 6

Author

dajana r

library(ggplot2)
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
nations <- read.csv("nations.csv")
nations2 <- nations |>
  mutate(GDP_T = gdp_percap * population/ 1e12)

chart1 <- nations2 |>
  filter(country %in% c("Germany","France","Belarus","Poland"))|>
  ggplot(aes(x = year, y = GDP_T, color = country)) +
  geom_point() +
  geom_line() +
  scale_color_brewer(palette = "Set1") +
  labs(title = "GDP of Western European Countries VS Eastern Euroepan Countries",
       x = "Year",
       y = "GDP (Trillions USD)",
       caption = "Source: Nations Dataset")
chart1

chart2 <- nations2 |>
  group_by(region, year) |>
  summarise(GDP = sum(GDP_T, na.rm = TRUE), .groups = "drop") |>
  ggplot(aes(x = year, y = GDP, fill = region)) +
  geom_area(color = "white", linewidth = 0.15) +
  scale_fill_brewer(palette = "Set2") +
  labs(title = "GDP by Region Over Time",
       x = "Year",
       y = "GDP (Trillions USD)",
       caption = "Source: Nations Dataset")
chart2

** Chat GPT was used to find and fix errors.