Load the Nations dataset
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.0 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.1 ✔ tibble 3.1.8
## ✔ 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 ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(dplyr)
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
setwd("C:/Users/myngu/OneDrive/Montgomery College/DATA 110/Data Sets")
Nations <- read.csv("nations.csv")
Mutate the data to get the nations GDP
GDP <- mutate(Nations, GDP = gdp_percap * population / 1000000000000)
Graph 1: South East Asia Uprising Four
SE_Asia_Four <- GDP %>%
filter(country == "Vietnam" | country == "Thailand" | country == "Malaysia" | country == "Singapore")
Graph1 <- SE_Asia_Four %>%
ggplot(aes(year, GDP, color = country)) +
geom_point() +
geom_line() +
ggtitle("SE Asia Uprising Four") +
ylab("GDP ($ Trillion)") +
xlab("Year") +
theme_minimal(base_size = 12) +
scale_color_brewer(palette = "Set1")
Graph1 <- ggplotly(Graph1)
Graph1
Graph 2: GDP by Region
GDP_Region_Year <- 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.
Graph2 <- GDP_Region_Year %>%
ggplot(aes(year, GDP, fill = region)) +
geom_area (color = "white", lwd = 0.25, linetype = 1) +
theme_minimal(base_size = 12) +
scale_fill_brewer(palette = "Set2") +
ggtitle("GDP by Region") +
ylab("GDP ($ Trillion)") +
xlab("Year")
Graph2 <- ggplotly(Graph2)
Graph2