get_wdi: Get World Development Indicators in 'xtdata' format

Description Usage Arguments Value Author(s) References See Also Examples

Description

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.

Usage

1
2
  get_wdi(x, country = "all", start = 1945, end = 2013,
    extra = NULL, aggregates = FALSE, ccode = "iso3c")

Arguments

x

the name(s) of the indicator(s) to download from the World Development Indicators API. See the documentation of the WDI function.

country

the ISO-2C country codes for which to download the indicators. Defaults to "all", which downloads all available data.

start

first year of data to download. Defaults to 1945.

end

last year of data to download. Defaults to 2012.

extra

a vector of additional variables from the WDI query that should be returned with the indicators. See the documentation of the WDI function, or set to TRUE to save all additional variables.

aggregates

whether to keep World Bank aggregates in the results, which causes the xtdata attribute to carry two data types, "country" and "aggregate". Defaults to FALSE.

ccode

the variable from which to create ISO-3N country codes. Defaults to iso3c, but might be set to any of the country variables returned by WDI. Intended for testing purposes.

Value

a data frame with country-year observations and an xtdata attribute

Author(s)

Francois Briatte f.briatte@ed.ac.uk

References

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.

See Also

WDI, xtdata

Examples

 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)
}

briatte/qogdata documentation built on May 13, 2019, 7:43 a.m.