NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true") knitr::opts_chunk$set( collapse = TRUE, comment = "#>", purl = NOT_CRAN )
library(pipr)
The pipr
package allows to easily query the PIP API from R.
Here are a few examples to get you started:
By default, get_stats()
returns all available
For the most recent data available.
get_stats()
# Specify ONE country get_stats(country = "ALB") # Specify MULTIPLE countries get_stats(country = c("ALB", "CHN"))
By default, get_stats
will only return data if a survey is available for the requested country and the requested year.
# Survey year available get_stats(country = "ALB", year = 2012) # single year get_stats(country = "ALB", year = c(1996,2012)) # multiple years # Survey year NOT available - Empty response get_stats(country = "ALB", year = 2000) # Most Recent Value available get_stats(country = "ALB", year = "MRV")
get_stats(country = "ALB", povline = 3.2)
The fill_gaps
argument triggers the interpolation / extrapolation of poverty
estimates when surveys are not available for a given year.
# fill_gaps = FALSE (default) get_stats(country = "HTI") # fill_gaps = TRUE get_stats(country = "HTI", fill_gaps = TRUE)
get_stats()
can also be used to compute aggregate welfare statistics for sub-regions.
Only World Bank regions are currently available, but more sub-regional groupings
will become available in the future.
# World Bank aggregate get_stats(country = "all", subgroup = "wb_regions") # List of World Bank regions get_regions()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.