library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.1 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
GDP_DATA <- read.csv("nations.csv")
gdp <- mutate(GDP_DATA, GDP = ((gdp_percap * population)/1000000000000))
gdp1 <- filter(gdp, country == "United States" | country == "Germany" | country == "China" | country == "France")
ggplot (gdp1, aes(x = year, y = GDP, color = country)) +
labs(title = "4 Large Countries' GDP",
y = "GDP ($Trillions)",
x = "Year") +
theme_minimal() +
geom_point() +
geom_line() +
scale_color_brewer(palette = 'Set1')

gdp2 <- gdp |>
group_by(region, year) |>
summarise(GDP = sum(GDP, na.rm = TRUE))
## `summarise()` has grouped output by 'region'. You can override using the
## `.groups` argument.
ggplot(gdp2, aes(x = year, y = GDP)) +
geom_area(aes(fill = region), colour = "white") +
labs(title = "GDP By Region",
y = "GDP ($Trillion)",
x = "Year")+
theme_minimal() +
scale_fill_brewer(palette = "Set2")
