WDI: World Development Indicators (World Bank)
Downloads the requested data by using the World Bank’s API, parses the resulting XML file, and formats it in long country-year format.
WDI(
country = "all",
indicator = "NY.GDP.PCAP.KD",
start = 1960,
end = NULL,
extra = FALSE,
cache = NULL,
latest = NULL,
language = "en"
)
country
Vector of countries (ISO-2 character codes, e.g. "BR", "US", "CA") for
which the data is needed. Using the string "all" instead of individual
iso codes pulls data for every available country.
indicator
Character vector of indicators codes. See the WDIsearch() function. If
you supply a named vector, the indicators will be automatically renamed:
‘c(’women_private_sector’ = ‘BI.PWK.PRVS.FE.ZS’)’
start
Start date, usually a year in integer format. Must be 1960 or greater.
end
End date, usually a year in integer format. Must be greater than the
‘start’ argument. If ‘NULL’, the end date is set to 5 years in the
future.
extra
TRUE returns extra variables such as region, iso3c code, and
incomeLevel. See Details.
cache
NULL (optional) a list created by WDIcache() to be used with the
extra=TRUE argument.
latest
Integer indicating the number of most recent non-NA values to get.
Default is NULL. If specified, it overrides the start and end dates.
language
ISO-2 code in lower case indicating in which language the characters
should be provided. List of languages available with
‘WDI::languages_supported()’. Default is English.
It is possible to only specify the ‘indicator’ and the ‘country’ arguments, in which case ‘WDI()’ will return data from 1960 to the last year available on World Bank’s website. It is also possible to get only the most recent non-NA values, with ‘latest’.
If ‘extra = TRUE’, additional variables are provided:
Data frame with country-year observations. You can extract a data.frame with indicator names and descriptive labels by inspecting the ‘label’ attribute of the resulting data.frame: ‘attr(dat, ’label’)’
Vincent Arel-Bundock vincent.arel-bundock@umontreal.ca
library(WDI)
WDI(country="all", indicator=c("AG.AGR.TRAC.NO","TM.TAX.TCOM.BC.ZS"),
start=1990, end=2000)
WDI(country=c("US","BR"), indicator="NY.GNS.ICTR.GN.ZS", start=1999, end=2000,
extra=TRUE, cache=NULL)
# Rename indicators on the fly
WDI(country = 'CA', indicator = c('women_private_sector' = 'BI.PWK.PRVS.FE.ZS',
'women_public_sector' = 'BI.PWK.PUBS.FE.ZS'))
# Get the 5 latest non-NA values
WDI(country=c("US","BR"), indicator="NY.GNS.ICTR.GN.ZS", latest = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.