Nations Charts Assignments

Author

Karen Kepm

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── 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
library(ggplot2)
library(RColorBrewer)
setwd("C:/Users/karen/OneDrive/Desktop/DATA 110")
nations <- read_csv("nations.csv")
Rows: 5275 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): iso2c, iso3c, country, region, income
dbl (5): year, gdp_percap, population, birth_rate, neonat_mortal_rate

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

5 Countries to have hosted FIFA World Cup Twice

Nat_wgdpercap <- nations %>%
  select(country, year, gdp_percap, population, region) %>%
  mutate(gdp_trillions = (gdp_percap * population) / 1000000000000)
filt <- Nat_wgdpercap %>%
  filter(country %in% c("Brazil", "Italy", "France", "Mexico", "Germany" ))
WCFIFA <- ggplot(filt, aes(x = year, y = gdp_trillions, col = country)) +
  scale_color_brewer(palette = "Set1") +
  xlab("Year") +
  ylab("GDP in Trillions of Dollars")  +
  theme_bw( base_size = 12)
WCFIFA + 
  geom_point() +
  geom_line() 

Nat_2 <- Nat_wgdpercap %>%
  filter(year >= 2000) %>%
  group_by(region, year) %>%
  summarise(GDP = sum(gdp_trillions, na.rm = TRUE))
`summarise()` has grouped output by 'region'. You can override using the
`.groups` argument.
Thebear <- ggplot(Nat_2, aes(x = year, y = GDP, fill = region)) +
  scale_fill_brewer(palette = "Set2") +
  xlab("Year") +
  ylab("GDP in Trillions of Dollars") +
  theme_bw(base_size = 12)
Thebear + 
  geom_area(outline.type = "full", col = "BLACK") + 
  ggtitle("GDP by World Bank Region")