Description Usage Arguments Value Author(s) References See Also Examples
Function to download World Development Indicators (WDI)
through the World Bank API, using the
WDI
package. The
countrycode
package is also
used to add ISO-3N country codes to the data frame. The
result carries an xtdata
attribute that can
be passed to the xtmerge
panel data method.
1 2 |
x |
the name(s) of the indicator(s) to download from
the World Development Indicators API. See the
documentation of the |
country |
the ISO-2C country codes for which to
download the indicators. Defaults to |
start |
first year of data to download. Defaults to
|
end |
last year of data to download. Defaults to
|
extra |
a vector of additional variables from the
WDI query that should be returned with the indicators.
See the documentation of the |
aggregates |
whether to keep World Bank aggregates
in the results, which causes the |
ccode |
the variable from which to create ISO-3N
country codes. Defaults to |
a data frame with country-year observations and an
xtdata
attribute
Francois Briatte f.briatte@ed.ac.uk
Arel-Bundock, Vincent. 2012. WDI: World Development Indicators (World Bank). R package version 2.2. http://CRAN.R-project.org/package=WDI
World Bank. 2013. World Development Indicators. Washington DC: The World Bank Group. Online publication, January 24, 2013.
1 2 3 4 5 6 7 8 9 10 11 12 13 | if(require(WDI) & require(ggplot2)) {
# Download WDI series with income classification.
WDI = get_wdi(x = "SH.XPD.PCAP.PP.KD", extra = "income")
# Merge to QOG time series demo data that contains identical indicator.
QOG = xtmerge(qog.ts.demo, WDI)
# Compare measurements: dots are QOG data points, lines are WDI data points.
qplot(data = subset(QOG, !is.na(wdi_hec)),
x = year, y = wdi_hec, color = income, alpha = I(.5)) +
geom_smooth(aes(y = SH.XPD.PCAP.PP.KD, group = ccode), se = FALSE) +
scale_colour_brewer("", palette = "RdYlBu") +
labs(y = NULL, x = NULL) +
theme_minimal(16)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.