A dashboard to compare macroeconomic indicators of the 2022 World Cup countries.
ShinyApp link: https://schoulten.shinyapps.io/macrocopa/
This dashboard is an intersection between economics and soccer, taking advantage of the 2022 World Cup event as its theme. The main idea of the dashboard is to allow the user to quickly compare the economic performance of two participating countries in the competition.
Key features:
- Interactive charts;
- Button to select pairs of countries for comparison;
- Button to select macroeconomic variables for comparison (GDP, inflation rate, interest rate, unemployment rate, exchange rate);
- Button for interactive time filter;
- Button to select chart type (line, column, or area);
- Button for data download.
The data comes from the World Bank, using the World Development Indicators (WDI) dataset, and is described below:
Variable | Description | Source |
---|---|---|
GDP | Annual growth, % | World Bank (WDI) |
Unemployment | Total, % of total labor force, national estimate, annual | World Bank (WDI) |
Inflation | Consumer prices, %, annual | World Bank (WDI) |
Interest rate | Deposit, %, annual | World Bank (WDI) |
Exchange rate | Official, LCU per US$, period average, annual | World Bank (WDI) |
This project was built using several technologies and the development process is summarized in the flowchart below.
flowchart LR
subgraph ETL
direction TB
DBnomics-->dplyr-->CSV
end
subgraph Development
direction LR
CSS-->Flexdashboard
JavaScript-->Highcharts
subgraph R
direction LR
Tidyverse-->Highcharts
Tidyverse-->Flexdashboard
Highcharts-->Shiny
Flexdashboard-->Shiny
end
end
subgraph Deploy
direction LR
output[Shinyapps.io]
end
ETL-->Development-->Deploy
-
ETL: to extract, transform, and load the data, we used the DBnomics database, which provides a data API for various sources, including World Bank. The process was developed using the R language, and a CSV file with the data was generated at the end.
-
Dashboard development: we used Flexdashboard and Shiny together to structure the HTML page with a template and add interactivity and buttons to the dashboard, using CSS and JS when necessary for customization. Additional data manipulations were made with Tidyverse, and the graphics were generated with Highcharts.
-
Deploy: to publish the dashboard, we used the Shinyapps.io service from Posit.
Finally, we used renv
for project
dependency (package) management, and all the tools used are open source
and free.
To replicate this ShinyApp, follow these steps:
- Clone the repository (terminal):
git clone https://github.com/schoulten/macrocopa.git
-
Open the RStudio project (macrocopa.Rproj file).
-
Restore the project dependencies (R Console):
renv::restore()
- Run the ShinyApp locally (R Console):
rmarkdown::run()
You should obtain a screen similar to this as a result:
- Fix CSS for country titles (H1 element)
- Add GitHub Action to automate ETL and deploy
- Refactor for more functional code
- Optimize for mobile interfaces