Helper functions and advanced examples

library(povcalnetR)
library(dplyr)
library(purrr)

Specify parameters at the country level

This function can be very handy is you maintain a list of countries and parameters in a table like the one below. Note: This function only works with survey years. There is no fill_gaps option available

# Read values from a table
data("sample_input")
sample_input
#> # A tibble: 5 x 5
#>   country poverty_line  year   ppp coverage_type
#>   <chr>          <dbl> <dbl> <dbl> <chr>        
#> 1 ALB              3.2  1996    50 national     
#> 2 AGO              1.9  2008    50 national     
#> 3 KAZ              3.2  1993    50 national     
#> 4 BOL              3.2  1992    50 urban        
#> 5 ZAF              5.5  1993    50 national
# Use table values to send a request to the API
# Only works for survey years
povcalnet_cl(country = sample_input$country,
             povline = sample_input$poverty_line,
             year = sample_input$year,
             ppp = sample_input$ppp)
#> # A tibble: 4 x 31
#>   countrycode countryname regioncode coveragetype  year datayear datatype
#>   <chr>       <chr>       <chr>      <chr>        <dbl>    <dbl> <chr>   
#> 1 ALB         Albania     ECA        N             1996    1996  consump~
#> 2 AGO         Angola      SSA        N             2008    2008. consump~
#> 3 KAZ         Kazakhstan  ECA        N             1993    1993  income  
#> 4 ZAF         South Afri~ SSA        N             1993    1993  consump~
#> # ... with 24 more variables: isinterpolated <dbl>, usemicrodata <dbl>,
#> #   ppp <dbl>, povertyline <dbl>, mean <dbl>, headcount <dbl>,
#> #   povertygap <dbl>, povertygapsq <dbl>, watts <dbl>, gini <dbl>,
#> #   median <dbl>, mld <dbl>, polarization <dbl>, population <dbl>,
#> #   decile1 <dbl>, decile2 <dbl>, decile3 <dbl>, decile4 <dbl>,
#> #   decile5 <dbl>, decile6 <dbl>, decile7 <dbl>, decile8 <dbl>,
#> #   decile9 <dbl>, decile10 <dbl>

Helper functions

Information table

Get all available countries from a World Bank region

Get all available countries from a World Bank income classification

Combining functions

Pass different poverty lines to countries from different income groups