Let’s use the wbstats package for R:

# install.packages("wbstats") # install for first use
library(wbstats) # load package

Search for indicators

https://data.worldbank.org/indicator

  • NY.GDP.PCAP.CD GDP per capita (current USD)
  • NY.GDP.PCAP.KD.ZG (GDP per capita growth rate)
  • SL.UEM.TOTL.ZS (total unemployment rate)
  • SL.TLF.CACT.FE.ZS female labor force participation rate
  • SL.TLF.CACT.MA.ZS male labor force participation rate
  • FP.CPI.TOTL.ZG inflation (CPI)
  • GC.DOD.TOTL.GD.ZS debt-percent-of-gdp
  • SP.POP.TOTL total population
  • SP.POP.GROW pop growth
  • SI.POV.GINI Gini
  • SP.DYN.LE00.IN total life expectancy at birth
  • SP.DYN.IMRT.IN infant mortality rate total per 1000 births
  • SI.POV.DDAY poverty headcount ratio 1.90 per day % of pop
  • NE.TRD.GNFS.ZS trade % of gdp
  • DT.ODA.OATL.CD net official aid received (current USD)
# example of searching manually in the system (vs online)
wbsearch(pattern = "unemployment")
ABCDEFGHIJ0123456789
 
 
indicatorID
<chr>
35WP15177.9
36WP15177.8
37WP15177.7
38WP15177.6
39WP15177.5
40WP15177.4
41WP15177.3
42WP15177.2
43WP15177.10
44WP15177.1

Figure out what country code is in World Bank (e.g. “US” for United States)

usa<-wb(country = c("US"),
   indicator = c("NY.GDP.PCAP.CD", "NY.GDP.PCAP.KD.ZG", "SL.UEM.TOTL.ZS", "FP.CPI.TOTL.ZG", "GC.DOD.TOTL.GD.ZS", "SP.POP.TOTL", "SP.POP.GROW", "SI.POV.GINI", "SP.DYN.LE00.IN", "SP.DYN.IMRT.IN", "SI.POV.DDAY", "NE.TRD.GNFS.ZS"),
   startdate = 1970, enddate = 2019,
   return_wide = TRUE) %>%
  mutate(date = as.numeric(date)) %>%
  rename("Year" = date,
         "GDP_per_Capita"= NY.GDP.PCAP.CD,
         "GDP_growth" = NY.GDP.PCAP.KD.ZG,
         "Unemployment" = SL.UEM.TOTL.ZS,
         "Inflation" = FP.CPI.TOTL.ZG,
         "Debt_pct_GDP" = GC.DOD.TOTL.GD.ZS,
         "Population" = SP.POP.TOTL,
         "Pop_growth" = SP.POP.GROW,
         "Gini" = SI.POV.GINI,
         "Life_Exp" = SP.DYN.LE00.IN,
         "Infant_mortality" = SP.DYN.IMRT.IN,
         "Poverty_pct" = SI.POV.DDAY,
         "Trade_pct_GDP" = NE.TRD.GNFS.ZS)
usa
ABCDEFGHIJ0123456789
iso3c
<chr>
Year
<dbl>
iso2c
<chr>
country
<chr>
Inflation
<dbl>
Debt_pct_GDP
<dbl>
Trade_pct_GDP
<dbl>
GDP_per_Capita
<dbl>
USA1970USUnited States5.8382553NA10.758295234.297
USA1971USUnited States4.2927667NA10.757185609.383
USA1972USUnited States3.2722782NA11.340626094.018
USA1973USUnited States6.1777601NA13.079296726.359
USA1974USUnited States11.0548048NA16.444997225.691
USA1975USUnited States9.1431469NA15.516377801.457
USA1976USUnited States5.7448126NA16.048858592.254
USA1977USUnited States6.5016840NA16.417899452.577
USA1978USUnited States7.6309638NA16.9728310564.948
USA1979USUnited States11.2544711NA18.3761911674.186
ggplot(data = usa)+
  aes(x = Year,
      y = GDP_per_Capita)+
  #geom_point()+
  geom_path(size=2, color = "blue")+
  scale_x_continuous(breaks=seq(1970,2020,10))+
  scale_y_continuous(breaks=seq(10000,60000,10000),
                                labels=scales::dollar)+
    theme_classic(base_family = "Fira Sans Condensed", base_size=18)+
  labs(x = "Year",
       y = "GDP per Capita (Current USD)")
## Warning: Removed 1 rows containing missing values (geom_path).

ggplot(data = usa)+
  aes(x = Year,
      y = Unemployment)+
  #geom_point()+
  geom_path(size=2, color = "blue")+
  scale_x_continuous(breaks=seq(1970,2020,10))+
  scale_y_continuous(labels=function(x){paste(x,"%")})+
    theme_classic(base_family = "Fira Sans Condensed", base_size=18)+
  labs(x = "Year",
       y = "Unemployment Rate (%)")
## Warning: Removed 21 rows containing missing values (geom_path).

ggplot(data = usa)+
  aes(x = Year,
      y = GDP_growth)+
  #geom_point()+
  geom_path(size=2, color = "blue")+
  geom_hline(yintercept=0, size =1)+
  scale_x_continuous(breaks=seq(1970,2020,10))+
  scale_y_continuous(labels=function(x){paste(x,"%")})+
    theme_classic(base_family = "Fira Sans Condensed", base_size=18)+
  labs(x = "Year",
       y = "GDP per Capita Growth")
## Warning: Removed 1 rows containing missing values (geom_path).