Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.

Original


*Source: https://howmuch.net/articles/the-world-economy-2017*


Objective

Explain the objective of the original data visualisation and the targetted audience.

The visualisation chosen had the following three main issues:

Reference

Code

The following code was used to fix the issues identified in the original.

 library(WDI)
 library(ggplot2)
 library(maps)
 library(rworldmap)
 library(tidyverse)
 library(plotly)
 library(ggfittext)
 library(magrittr)
 library(ggiraph)

 options(scipen = 999)
 dat = WDI(indicator='NY.GDP.MKTP.CD',extra=T ,start=2017, end=2017)
 dat$longitude <- as.numeric(levels(dat$longitude))[dat$longitude]
 dat$latitude <- as.numeric(levels(dat$latitude))[dat$latitude]
 dat$NY.GDP.MKTP.CD <- as.numeric(as.character(dat$NY.GDP.MKTP.CD))
 
 dat$NY.GDP.MKTP.CD <- dat$NY.GDP.MKTP.CD / 1000000000
 
 dat$NY.GDP.MKTP.CD  <- round(dat$NY.GDP.MKTP.CD ,2)
 
 dat_map <- joinCountryData2Map(dat, joinCode = "ISO2", nameJoinColumn = "iso2c")
## 214 codes from your data successfully matched countries in the map
## 50 codes from your data failed to match with a country code in the map
## 27 codes from the map weren't represented in your data
 dat_map_pol <- fortify(dat_map)
 dat_map_pol <- merge(dat_map_pol, dat_map@data, by.x="id", by.y="ADMIN", all.x=T)

Data Reference

Reconstruction

The following plot fixes the main issues in the original.