Nations Dataset

Author

Arif

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
setwd("/Users/arifjadji/Desktop/DATA110/DATA110 Datasets")
gdp <- read_csv(file = "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.
gdp1 <- mutate(gdp, GDP = ((gdp_percap * population)/1000000000000))
gdp2 <- filter(gdp1, country == "Switzerland" | country == "Canada" | country == "China" | country == "United States")
ggplot (gdp2, aes(x = year, y = GDP, color = country)) +
  ylab("GDP($ trillion)") +
  ggtitle("Four Chosen Country's Economy Outlooks") +
  geom_point() +
  geom_line() +
  scale_color_brewer(palette = 'Set1')

gdp3 <- gdp1 %>% 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(gdp3, aes(year, GDP)) +
         xlab("Year") + ylab("GDP($ trillion)") +
         scale_fill_brewer(palette = 'Set2') +
         ggtitle("GDP For Each Region") +
         geom_area(colour = "white", aes(fill = region))