API: WDI

Access global development data through the WDI API.

Table of Contents


By using SKEMA Quantum Studio framework (Warin 2019), this course will teach you how to use the WDI package.

Database description

“The primary World Bank collection of development indicators, compiled from officially-recognized international sources. It presents the most current and accurate global development data available, and includes national, regional and global estimates” (World Development Indicators, The World Bank)

World bank : https://www.worldbank.org/

Functions

This library gives access to all indicators provided by the World Bank. The functions listed below allow you to search and download specific data from the WDI database.

Each of these functions are detailed in this course and some examples are provided.

WDIsearch()

The function WDIsearch() takes as an input any string of character and will provide the list of indicators containing this string of character.

For example, we would like to obtain all indicators using the term “GDP” from the database WDI.


#Loading the WDI library
library(WDI)

# Search all indicators with the term "GDP"
listOfIndicators <- WDIsearch("GDP")

# List the first 5 indicators
listOfIndicators[1:5,]

     indicator             
[1,] "BX.TRF.PWKR.GD.ZS"   
[2,] "BX.TRF.PWKR.DT.GD.ZS"
[3,] "BX.TRF.MGR.DT.GD.ZS" 
[4,] "BX.KLT.DINV.WD.GD.ZS"
[5,] "BX.KLT.DINV.DT.GD.ZS"
     name                                               
[1,] "Workers' remittances, receipts (% of GDP)"        
[2,] "Personal remittances, received (% of GDP)"        
[3,] "Migrant remittance inflows (% of GDP)"            
[4,] "Foreign direct investment, net inflows (% of GDP)"
[5,] "Foreign direct investment, net inflows (% of GDP)"

WDI()

The function WDI() takes as an input the indicator’s code and the country of the data wanted. It returns the value of the indicator for the countries selected. To search specific dates, it is possible to add as inputs the starting year and the ending year of the data.

For example, it would be interesting to evaluate the total amount of stocks traded in percentage of GDP (CM.MKT.TRAD.GD.ZS) for 4 countries (France - FR; Canada - CA; USA - US; China - CN) from 2000 to 2014. This could be obtained by using the function WDI() with the following inputs:


# Access and store data concerning Stocks traded in total value (% of GDP)
stockTraded <- WDI(indicator = "CM.MKT.TRAD.GD.ZS", country = c("FR", "CA", "US","CN"), start = 2000, end = 2016)

head(stockTraded)

  iso2c country CM.MKT.TRAD.GD.ZS year
1    CA  Canada          75.54611 2016
2    CA  Canada          70.59498 2015
3    CA  Canada          74.61698 2014
4    CA  Canada          71.85495 2013
5    CA  Canada          73.91277 2012
6    CA  Canada          82.38894 2011

tl;dr


#Loading the WDI library
library(WDI)

# Search all indicators with the term "GDP"
listOfIndicators <- WDIsearch("GDP")

# List the first 5 indicators
listOfIndicators[1:5,]

stockTraded <- WDI(indicator = "CM.MKT.TRAD.GD.ZS", country = c("FR", "CA", "US","CN"), start = 2000, end = 2016)

head(stockTraded)

Code learned this week

Command Detail
WDIsearch() Search for world bank indicators
WDI() Find data related to the indicators for each country

References

This course uses the WDI package documentation


Warin, Thierry. 2019. “SKEMA Quantum Studio: A Technological Framework for Data Science in Higher Education.” https://doi.org/10.6084/m9.figshare.8204195.v2.

Citation

For attribution, please cite this work as

Warin (2020, Jan. 29). Virtual Campus: API: WDI. Retrieved from https://virtualcampus.skemagloballab.io/posts/api-wdi/

BibTeX citation

@misc{warin2020api:,
  author = {Warin, Thierry},
  title = {Virtual Campus: API: WDI},
  url = {https://virtualcampus.skemagloballab.io/posts/api-wdi/},
  year = {2020}
}