wbwdi
is an R package to access and analyze the World
Bank’s World Development Indicators (WDI) using the corresponding API.
WDI provides more than 24,000 country or region-level indicators for
various contexts. wbwdi
enables users to download, process
and work with WDI series across multiple entities and time periods.
The package is designed to work seamlessly with International Debt
Statistics (IDS) provided through the wbids
package and shares its syntax with its sibling Python library wbwdi
.
It follows the principles of the econdataverse.
This package is a product of Christoph Scheuch and not sponsored by or affiliated with the World Bank in any way, except for the use of the World Bank WDI API.
You can install wbwdi
from CRAN via:
install.packages("wbwdi")
You can install the development version of wbwdi
like
this:
::pak("tidy-intelligence/r-wbwdi") pak
The main function wdi_get()
provides an interface to
download multiple WDI series for multiple entities and specific date
ranges.
wdi_get(
entities = c("MX", "CA", "US"),
indicators = c("NY.GDP.PCAP.KD", "SP.POP.TOTL"),
start_year = 2020, end_year = 2024
)
You can also download these indicators for all entities and available dates:
wdi_get(
entities = "all",
indicators = c("NY.GDP.PCAP.KD", "SP.POP.TOTL")
)
Some indicators are also available on a monthly basis, e.g.:
wdi_get(
entities = "AUT",
indicators = "DPANUSSPB",
start_year = 2012, end_year = 2015,
frequency = "month"
)
Similarly, there are also some indicators available on a quarterly frequency, e.g.:
wdi_get(
entities = "NGA",
indicators = "DT.DOD.DECT.CD.TL.US",
start_year = 2012, end_year = 2015,
frequency = "quarter"
)
You can get a list of all indicators supported by the WDI API via:
wdi_get_indicators()
You can get a list of all supported entities via:
wdi_get_entities()
You can also get the list of supported indicators and entities in another language, but note that not everything seems to be translated into other languages:
wdi_get_indicators(language = "es")
wdi_get_entities(language = "zh")
Check out the following function for a list of supported languages:
wdi_get_languages()
In addition, you can list supported regions, sources, topics and lending types, respectively:
wdi_get_regions()
wdi_get_sources()
wdi_get_topics()
wdi_get_lending_types()
If you want to search for specific keywords among indicators or other data sources, you can use the RStudio or Positron data explorer. Alternatively, this package comes with a helper function:
<- wdi_get_indicators()
indicators wdi_search(
indicators,keywords = c("inequality", "gender"),
columns = c("indicator_name")
)
The most important differences to existing packages are that
wbwdi
is designed to (i) have a narrow focus on World Bank
Development Indicators, (ii) have a consistent interface with other R
packages (e.g., wbids
),
(iii) have an MIT license, and (iv) have a shared interface with Python
libraries (e.g., wbwdi
).
wbwdi
also refrains from using cached data because this
approach frequently leads to problems for users due to outdated caches
and it uses httr2
to manage API requests and parse
responses.
More specifically, the differences of existing CRAN releases (apart from interface design) are:
WDI
: uses
cached data by default, does not allow downloading meta data from the
WDI API (e.g., languages, sources, topics), has a GPL-3 license, and
does neither use httr
nor httr2
for
requests.worldbank
:
does not have a narrow focus because it includes the Poverty and
Inequality Platform and Finances One API.wbstats
:
uses cached data by default, does not use httr2
.