library(readr)
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
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
library(gganimate)
library(transformr)
library(gifski)
library(av)
Indicators <- read_csv("Economic Indicators.csv")
## Rows: 304 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Country
## dbl (5): Year, GDP (in billion USD), Inflation Rate (%), Unemployment 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.
head(Indicators)
## # A tibble: 6 × 6
## Country Year `GDP (in billion USD)` `Inflation Rate (%)`
## <chr> <dbl> <dbl> <dbl>
## 1 USA 2010 15000 1.64
## 2 USA 2011 15500 3.16
## 3 USA 2012 16000 2.07
## 4 USA 2013 16500 1.5
## 5 USA 2014 17000 1.62
## 6 USA 2015 17500 0.12
## # ℹ 2 more variables: `Unemployment Rate (%)` <dbl>,
## # `Economic Growth (%)` <dbl>
The dataset contains information on macroeconomic indicators for multiple countries over several years. Here are the variables:
Country: Country name (character)Year: Observation year (numeric)GDP (in billion USD): Country’s GDP (numeric)Inflation Rate (%): Annual inflation rate
(numeric)Unemployment Rate (%): Unemployment rate (numeric)Economic Growth (%): Annual growth rate (numeric)# Subset for emerging market countries
selected_countries <- c("Bangladesh", "India", "Indonesia", "Malaysia",
"Pakistan", "Vietnam")
FilteredIndicators <- Indicators %>%
filter(Country %in% selected_countries)
ggplot(FilteredIndicators, aes(x = Year, y = `GDP (in billion USD)`, color = Country)) +
geom_line(linewidth = 1.0) +
labs(title = "GDP Trends (2010-2025)",
subtitle = "Emerging Markets",
x = "Year",
y = "GDP (in Billion USD)",
color = "Country") +
theme_minimal()
ggplot(FilteredIndicators, aes(x = Year, y = `Inflation Rate (%)`, color = Country)) +
geom_line(linewidth = 1) +
labs(
title = "Inflation Trends (2010–2025)",
subtitle = "Emerging Markets",
x = "Year",
y = "Inflation Rate (%)",
color = "Country"
) +
theme_light()
p1 <- ggplot(FilteredIndicators, aes(x = Year, y = `GDP (in billion USD)`, color = Country)) +
geom_line(linewidth = 1.0) +
labs(title = "GDP Trends (2010–2025)",
subtitle = "Emerging Markets",
x = "Year",
y = "GDP (in Billion USD)",
color = "Country") +
theme_minimal()
ggplotly(p1)
p2 <- ggplot(FilteredIndicators, aes(x = Year, y = `Inflation Rate (%)`, color = Country)) +
geom_line(linewidth = 1) +
labs(
title = "Inflation Trends (2010–2025)",
subtitle = "Emerging Markets",
x = "Year",
y = "Inflation Rate (%)",
color = "Country"
) +
theme_light()
ggplotly(p2)
Animated_GDP <- ggplot(FilteredIndicators, aes(x = `Economic Growth (%)`,
y = Country,
color = Country)) +
geom_point(size = 6, alpha = 0.8) +
labs(
title = "Economic Growth Rates Over Time: {frame_time}",
x = "Economic Growth (%)",
y = "Country"
) +
xlim(0, NA) +
transition_time(Year) +
ease_aes('linear') +
theme_minimal(base_size = 14) +
theme(legend.position = "none")
Animated_GDP
animate(Animated_GDP, fps = 5, renderer = gifski_renderer())