Package wbstats. R topics documented: January 3, Type Package

Similar documents
Package fitbitscraper

Package statsdk. September 30, 2017

Package docxtools. July 6, 2018

Bulk download in ILOSTAT:

Bulk download in ILOSTAT:

Package darksky. September 20, 2017

Package censusapi. August 19, 2018

Package opencage. January 16, 2018

Package gtrendsr. October 19, 2017

Package cancensus. February 4, 2018

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package dkanr. July 12, 2018

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package states. May 4, 2018

Package gtrendsr. August 4, 2018

Package riingo. April 16, 2018

Package robotstxt. November 12, 2017

Package spelling. December 18, 2017

Package websearchr. R topics documented: October 23, 2018

Package bisect. April 16, 2018

Package rzeit2. January 7, 2019

Package readxl. April 18, 2017

Package postal. July 27, 2018

Package ezsummary. August 29, 2016

Package guardianapi. February 3, 2019

Package calpassapi. August 25, 2018

Package wikitaxa. December 21, 2017

Package fastdummies. January 8, 2018

Package rgho. R topics documented: January 18, 2017

Package repec. August 31, 2018

Package rwars. January 14, 2017

Package SEMrushR. November 3, 2018

Package bigqueryr. October 23, 2017

Package facerec. May 14, 2018

Package RWildbook. April 6, 2018

Package PxWebApiData

Package goodpractice

Package BANEScarparkinglite

Package patentsview. July 12, 2017

Package edfreader. R topics documented: May 21, 2017

Package crossword.r. January 19, 2018

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

Package internetarchive

Package httpcache. October 17, 2017

Package oec. R topics documented: May 11, Type Package

Package rgdax. January 7, 2019

Package labelvector. July 28, 2018

Package Tushare. November 2, 2018

Package edear. March 22, 2018

Package smapr. October 20, 2017

Package filematrix. R topics documented: February 27, Type Package

Package AdhereR. June 15, 2018

Package elasticsearchr

Package postgistools

Package tm.plugin.lexisnexis

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package datasets.load

Package cronr. March 3, 2017

Package bigqueryr. June 8, 2018

Package WikipediR. February 5, 2017

Package genesysr. June 14, 2018

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package narray. January 28, 2018

Package bizdays. June 25, 2018

Package xtractomatic

Package pdfetch. October 15, 2017

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package githubinstall

Package virustotal. May 1, 2017

Package rbraries. April 18, 2018

Package eurostat. August 9, 2017

Package lumberjack. R topics documented: July 20, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package bikedata. April 27, 2018

Package loggit. April 9, 2018

Package jpmesh. December 4, 2017

Package reconstructr

Package jug. April 13, 2017

Package xtractomatic

Package GetITRData. October 22, 2017

Package ECctmc. May 1, 2018

Package edgarwebr. December 22, 2017

Package kdtools. April 26, 2018

Package gfer. March 11, 2018

Package urltools. October 17, 2016

Package GetHFData. November 28, 2017

Package omu. August 2, 2018

Package mfbvar. December 28, Type Package Title Mixed-Frequency Bayesian VAR Models Version Date

Package padr. November 16, 2017

Package semver. January 6, 2017

Package anomalize. April 17, 2018

Package rdryad. June 18, 2018

Package confidence. July 2, 2017

Package haven. April 9, 2015

Package widyr. August 14, 2017

Package meme. November 2, 2017

Package splithalf. March 17, 2018

Package ggseas. June 12, 2018

Package aws.transcribe

Transcription:

Type Package Package wbstats January 3, 2018 Title Programmatic Access to Data and Statistics from the World Bank API Tools for searching and downloading data and statistics from the World Bank Data API (<http://data.worldbank.org/developers/api-overview>) and the World Bank Data Catalog API (<http://data.worldbank.org/developers/data-catalog-api>). Version 0.2 Date 2018-01-01 Maintainer Jesse Piburn <piburnjo@ornl.gov> URL https://github.com/gist-ornl/wbstats License MIT + file LICENSE LazyData TRUE Depends R (>= 3.1) Imports httr, jsonlite, tidyr Suggests ggplot2, knitr, lubridate (>= 1.5.0) VignetteBuilder knitr Roxygen 6.0.1 NeedsCompilation no Author Jesse Piburn [aut, cre], UT-Battelle, LLC [cph] Repository CRAN Date/Publication 2018-01-03 18:21:36 UTC R topics documented: call_api........................................... 2 wb.............................................. 3 wbcache........................................... 5 wbcountries......................................... 7 wbdatacatalog........................................ 8 1

2 call_api wbdate2posixct...................................... 8 wbformatcols........................................ 9 wbget............................................ 9 wbget_dc.......................................... 10 wbincome.......................................... 10 wbindicators......................................... 11 wblending.......................................... 12 wbsearch.......................................... 13 wbsources.......................................... 13 wbstats........................................... 14 wbtopics........................................... 15 wburls............................................ 16 wb_cachelist........................................ 16 Index 17 call_api Call the World Bank API and return list To be used inside of wbget() call_api(url_string, indicator) url_string indicator A character string. A formatted url string A character string. indicatorid for request. Used for error returns json contents of page information

wb 3 wb Download Data from the World Bank API This function downloads the requested information using the World Bank API wb(country = "all", indicator, startdate, enddate, mrv, return_wide = FALSE, gapfill, freq, cache, lang = c("en", "es", "fr", "ar", "zh"), removena = TRUE, POSIXct = FALSE, include_dec = FALSE, include_unit = FALSE, include_obsstatus = FALSE, include_lastupdated = FALSE) country Character vector of country or region codes. Default value is special code of all. Other permissible values are codes in the following fields from the wb_cachelist country data frame. iso3c, iso2c, regionid, adminid, and incomeid. Additional special values include aggregates, which returns only aggregates, and countries_only, which returns all countries without aggregates. indicator startdate enddate Character vector of indicator codes. These codes correspond to the indicatorid column from the indicator data frame of wbcache or wb_cachelist, or the result of wbindicators Numeric or character. If numeric it must be in %Y form (i.e. four digit year). For data at the subannual granularity the API supports a format as follows: for monthly data, "2016M01" and for quarterly data, "2016Q1". This also accepts a special value of "YTD", useful for more frequently updated subannual indicators. Numeric or character. If numeric it must be in %Y form (i.e. four digit year). For data at the subannual granularity the API supports a format as follows: for monthly data, "2016M01" and for quarterly data, "2016Q1". mrv Numeric. The number of Most Recent s to return. A replacement of startdate and enddate, this number represents the number of observations you which to return starting from the most recent date of collection. Useful in conjuction with freq return_wide Logical. If TRUE data is returned in a wide format instead of long, with a column named for each indicatorid. To necessitate this transformation, the indicator column, that provides the human readable description is dropped. This field is available through from the indicator data frame of wbcache or wb_cachelist, or the result of wbindicators. Default is FALSE gapfill Logical. Works with mrv. If TRUE fills values, if not available, by back tracking to the next available period (max number of periods back tracked will be limited by mrv number)

4 wb freq cache lang removena POSIXct include_dec Character String. For fetching quarterly ("Q"), monthly("m") or yearly ("Y") values. Currently works along with mrv. Useful for querying high frequency data. List of data frames returned from wbcache. If omitted, wb_cachelist is used Language in which to return the results. If lang is unspecified, english is the default. if TRUE, remove any blank or NA observations that are returned. if FALSE, no blank or NA values are removed from the return. if TRUE, additonal columns date_ct and granularity are added. date_ct converts the default date into a POSIXct. granularity denotes the time resolution that the date represents. Useful for subannual data and mixing subannual with annual data. If FALSE, these fields are not added. if TRUE, the column decimal is not removed from the return. if FALSE, this column is removed include_unit if TRUE, the column unit is not removed from the return. if FALSE, this column is removed include_obsstatus if TRUE, the column obsstatus is not removed from the return. if FALSE, this column is removed include_lastupdated if TRUE, the column lastupdated is not removed from the return. if FALSE, this column is removed. If TRUE and POSIXct = TRUE then column will be of class Date Data frame with all available requested data. Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin The POSIXct parameter requries the use of lubridate (>= 1.5.0). All dates are rounded down to the floor. For example a value for the year 2016 would have a POSIXct date of 2016-01-01. If this package is not available and the POSIXct parameter is set to TRUE, the parameter is ignored and a warning is produced. The include_dec, include_unit, and include_obsstatus are defaulted to FALSE because as of writing, all returns have a value of 0, NA, and NA, respectively. These columns might be used in the future by the API, therefore the option to include the column is available.

wbcache 5 The include_lastupdated is defaulted to FALSE as well to limit the If there is no data available that matches the request parameters, an empty data frame is returned along with a warning. This design is for easy aggregation of multiple calls. # GDP at market prices (current US$) for all available countries and regions wb(indicator = "NY.GDP.MKTP.CD", startdate = 2000, enddate = 2016) # GDP and Population in long format for the most recent 20 observations wb(indicator = c("sp.pop.totl","ny.gdp.mktp.cd"), mrv = 20) # GDP and Population in wide format for the most recent 20 observations wb(indicator = c("sp.pop.totl","ny.gdp.mktp.cd"), mrv = 20, return_wide = TRUE) # query using regionid or incomeid # High Income Countries and Sub-Saharan Africa (all income levels) wb(country = c("hic", "SSF"), indicator = "NY.GDP.MKTP.CD", startdate = 1985, enddate = 1985) # if you do not know when the latest time an indicator is avaiable mrv can help wb(country = c("in"), indicator = 'EG.ELC.ACCS.ZS', mrv = 1) # increase the mrv value to increase the number of maximum number of returns wb(country = c("in"), indicator = 'EG.ELC.ACCS.ZS', mrv = 35) # GDP at market prices (current US$) for only available countries wb(country = "countries_only", indicator = "NY.GDP.MKTP.CD", startdate = 2000, enddate = 2016) # GDP at market prices (current US$) for only available aggregate regions wb(country = "aggregates", indicator = "NY.GDP.MKTP.CD", startdate = 2000, enddate = 2016) # if you want to "fill-in" the values in between actual observations use gapfill = TRUE # this highlights a very important difference. # all other parameters are the same as above, except gapfill = TRUE # and the results are very different wb(country = c("in"), indicator = 'EG.ELC.ACCS.ZS', mrv = 35, gapfill = TRUE) # if you want the most recent values within a certain time frame wb(country = c("us"), indicator = 'SI.DST.04TH.20', startdate = 1970, enddate = 2000, mrv = 2) # without the freq parameter the deafult temporal granularity search is yearly # should return the 12 most recent years of data wb(country = c("chn", "IND"), indicator = "DPANUSSPF", mrv = 12) # if another frequency is available for that indicator it can be accessed using the freq parameter # should return the 12 most recent months of data wb(country = c("chn", "IND"), indicator = "DPANUSSPF", mrv = 12, freq = "M") wbcache Download an updated list of country, indicator, and source information

6 wbcache Download an updated list of information regarding countries, indicators, sources, data catalog, indicator topics, lending types, and income levels from the World Bank API wbcache(lang = c("en", "es", "fr", "ar", "zh")) lang Language in which to return the results. If lang is unspecified, english is the default. A list containing the following items: countries: A data frame. The result of calling wbcountries indicators: A data frame.the result of calling wbindicators sources: A data frame.the result of calling wbsources datacatalog: A data frame.the result of calling wbdatacatalog topics: A data frame.the result of calling wbtopics income: A data frame.the result of calling wbincome lending: A data frame.the result of calling wblending Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin List item datacatalog will always return in english, as the API does not support any other langauges for that information. Saving this return and using it has the cache parameter in wb and wbsearch replaces the default cached version wb_cachelist that comes with the package itself # default is english. To specific another language use argument lang wbcache(lang = "es")

wbcountries 7 wbcountries Download updated country and region information from World Bank API Download updated information on available countries and regions from the World Bank API wbcountries(lang = c("en", "es", "fr", "ar", "zh")) lang Language in which to return the results. If lang is unspecified, english is the default. A data frame of available countries and regions with related information Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin wbcountries() wbcountries(lang = "es")

8 wbdate2posixct wbdatacatalog Download an updated list of the World Bank data catalog Download an updated list of the World Bank data catalog from the World Bank API wbdatacatalog() A data frame of the World Bank data catalog with related information This function does not support any languages other than english due to the lack of support from the World Bank API wbdatacatalog() wbdate2posixct Add a POSIXct dates to a World Bank API return Add a POSIXct date column as well as a column with the appropreiate granularity to a World Bank API return wbdate2posixct(df, date_col) df date_col data frame returned from API call name of the current date field If the package lubridate (>= 1.5.0) is available the original data frame with two new columns, data_ct and granularity is returned. If the above package is not available, the orignal data frame is returned unaltered with an additional warning message.

wbformatcols 9 wbformatcols Format column names of World Bank API returns change the name of columns that we know of to our standardized names. If there are new columns added that we don t know about, leave their name the same wbformatcols(df, col_names, blank2na = TRUE) df col_names blank2na data frame returned from API call a named vector of column names and what they will be changed to logical. If TRUE blank values are converted to NA a data frame with the column names changed accordingly wbget Call the World Bank API and return a formatted data frame This function calls wbget.raw and determines if there are multiple pages from the request. If there are multiple pages then if generates a list of data frames from each page and then combines the results with do.call("rbind", mylist) wbget(url_string, indicator) url_string indicator A character string. A formatted url string A character string. indicatorid for request. Used for error returns A data frame

10 wbincome wbget_dc Call the Data Catalog API Helper function for the data catalog call wbget_dc(url_string) url_string A charcter string. A formatted url string A list of data frames This call is seperate because the data catalog is actaully a different API and therefore has a different return structure. wbincome Download updated income type information from World Bank API Download updated information on available income types from the World Bank API wbincome(lang = c("en", "es", "fr", "ar", "zh")) lang Language in which to return the results. If lang is unspecified, english is the default. A data frame of available income types with related information

wbindicators 11 Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin wbincome() wbincome(lang = "es") wbindicators Download updated indicator information from World Bank API Download updated information on available indicators from the World Bank API wbindicators(lang = c("en", "es", "fr", "ar", "zh")) lang Language in which to return the results. If lang is unspecified, english is the default. A data frame of available indicators with related information Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin

12 wblending # default is english. To specific another language use argument lang wbindicators(lang = "es") wblending Download updated lending type information from World Bank API Download updated information on available lending types from the World Bank API wblending(lang = c("en", "es", "fr", "ar", "zh")) lang Language in which to return the results. If lang is unspecified, english is the default. A data frame of available lending types with related information Not all data returns have support for langauges other than english. If the specific return does notsupport your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin wblending() wblending(lang = "es")

wbsearch 13 wbsearch Search indicator information available through the World Bank API This function allows finds indicators that match a search term and returns a data frame of matching results wbsearch(pattern = "poverty", fields = c("indicator", "indicatordesc"), extra = FALSE, cache) pattern fields extra cache Character string or regular expression to be matched Character vector of column names through which to search if FALSE, only the indicator ID and short name are returned, if TRUE, all columns of the cache parameter s indicator data frame are returned List of data frames returned from wbcache. If omitted, wb_cachelist is used Data frame with indicators that match the search pattern. wbsearch(pattern = "education") wbsearch(pattern = "Food and Agriculture Organization", fields = "sourceorg") # with regular expression operators # 'poverty' OR 'unemployment' OR 'employment' wbsearch(pattern = "poverty unemployment employment") wbsources Download updated data source information from World Bank API Download updated information on available data sources from the World Bank API wbsources(lang = c("en", "es", "fr", "ar", "zh"))

14 wbstats lang Language in which to return the results. If lang is unspecified, english is the default. A data frame of available data scources with related information Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin wbsources() wbsources(lang = "es") wbstats wbstats: An R package for searching and downloading data from the World Bank API. The wbstats package provides structured access to all of the information available from the World Bank API including; support for mutliple languages, access to all annual, quarterly, and monthly data, as well as access to the World Bank Data Catalog API, which provides metadata on each data source, such as update schedules, last revisions, and coverage, among other information. Details To learn more about the wbstats package, start with the vignettes: browsevignettes(package = "wbstats")

wbtopics 15 wbtopics Download updated indicator topic information from World Bank API Download updated information on available indicator topics from the World Bank API wbtopics(lang = c("en", "es", "fr", "ar", "zh")) lang Language in which to return the results. If lang is unspecified, english is the default. A data frame of available indicator topics with related information Not all data returns have support for langauges other than english. If the specific return does not support your requested language by default it will return NA. For an enumeration of supported languages by data source please see wbdatacatalog. The options for lang are: en: English es: Spanish fr: French ar: Arabic zh: Mandarin wbtopics() wbtopics(lang = "es")

16 wb_cachelist wburls url chucks to be used in API calls This function is used inside other functions in this package wburls() a list with a base url and a url section for formatting the json return wb_cachelist Cached information from the World Bank API Format Details This data is a cached result of the wbcache function. By default functions wb and wbsearch use this data for the cache parameter. wb_cachelist A list containing 7 data frames: countries: A data frame. The result of calling wbcountries indicators: A data frame.the result of calling wbindicators sources: A data frame.the result of calling wbsources datacatalog: A data frame.the result of calling wbdatacatalog topics: A data frame.the result of calling wbtopics income: A data frame.the result of calling wbincome lending: A data frame.the result of calling wblending This data was updated using wbcache on January 1, 2018

Index Topic datasets wb_cachelist, 16 call_api, 2 Date, 4 lubridate, 4 POSIXct, 4 wb, 3, 6, 16 wb_cachelist, 3, 4, 6, 13, 16 wbcache, 3, 4, 5, 13, 16 wbcountries, 6, 7, 16 wbdatacatalog, 4, 6, 7, 8, 11, 12, 14 16 wbdate2posixct, 8 wbformatcols, 9 wbget, 9 wbget_dc, 10 wbincome, 6, 10, 16 wbindicators, 3, 6, 11, 16 wblending, 6, 12, 16 wbsearch, 6, 13, 16 wbsources, 6, 13, 16 wbstats, 14 wbstats-package (wbstats), 14 wbtopics, 6, 15, 16 wburls, 16 17