worldbank / povcalnetr Goto Github PK
View Code? Open in Web Editor NEWR client to the Povcalnet API
Home Page: https://worldbank.github.io/povcalnetR
License: Other
R client to the Povcalnet API
Home Page: https://worldbank.github.io/povcalnetR
License: Other
Currently, package internal variable are being defined at build time in add_internal_data.R
This is an issue for variables that are pulled from the API using povcalnet_info()
. This approach breaks in the following cases:
I am using povcalnetR
to get the poverty headcounts for each country in a loop. However, the loop always gets stuck at some point such that I have to force shut down my R software. After checking the code, I found that certain countries caused the problem, e.g.:
library(povcalnetR)
povcalnet(
country = "SUR", povline = 1.9, year = 2010:2021
)
If country="all"
, the code works fine, and the retrieved data will not contain information for the problematic country "SUR"
. It seems that if a country is not in the database, the data retrieval for that individual country will raise a bug.
Other information:
Hi Tony,
By default, the Stata package loads coverages levels when option coverage is left empty povcalnet, country("all")
. However, the R package filters everything that is not national by default. In this case, countries like Argentina, which does not have national coverage, are excluded from the output when povcalnet(country = "all")
is executed.
I could update that if you want, but I thought it would be better if you do it.
Thanks.
Best,
Andres
In more detail the results are as follows (the rest of countries seem to return poverty rates for all survey years when poverty lines other than 1.9 $ are requested--not necessarily the same for each year):
[1] "PCN request for ARG returns an empty tibble (own PLs)."
[1] "PCN request for BOL returns a tibble with less years (own PLs). Missing: 1992"
[1] "PCN request for COL returns a tibble with less years (own PLs). Missing: 1980;1988;1989;1991"
[1] "PCN request for ECU returns a tibble with less years (own PLs). Missing: 1995"
[1] "PCN request for ETH returns a tibble with less years (own PLs). Missing: 1981"
[1] "PCN request for HND returns a tibble with less years (own PLs). Missing: 1986"
[1] "PCN request for URY returns a tibble with less years (own PLs). Missing: 1992;1995;1996;1997;1998;2000;2001;2002;2003;2004;2005"
try:
povcalnet("GNB",10,1991)
gives: -1 to headcount povertygap povertygapsq watts
it should give 1 to headcount at least
The following lines of code will report a row with data for region SAS in 2015 but NAs for 2018.
library(povcalnetR)
regions <- povcalnet_wb()
regions <- regions[regions$regioncode == "SAS",]
regions[regions$year == 2015,]
regions[regions$year == 2018,]
The PovcalNet web interface, however, suppresses the results for both years as coverage in 2015 and 2018 in SAS is too low.
This inconsistency seems weird.
Ryan
The povcalnet
function uses readr::read_csv
to format the data. By the default configuration for readr
(version > 2.0), messages about the dataframe column types will pop up once the data is read. readr::read_csv
offers an argument show_col_types
to switch off the sometimes annoying messages. However, such an argument is not available when using povcalnet
.
When using the option fill_gaps=True, the regions are all returned as "XX."
poverty <- povcalnet(year = 2015, fill_gaps = TRUE)
poverty <- povcalnet(year = 2015)
Different coverage level mess up the aggregation behavior
It would appear that the povcalnet() function doesn't pull data for ARE. Even if I try using povcalnet(country = "ARE") it just returns an empty dataframe. Data exists on the povcal website so I'm not sure why the package ignores it.
Hi,
The argument fill_gaps
of povcalnet()
is described as "logical: 'TRUE' will interpolate / extrapolate values when surveys are not available for a specific year." However, no interpolated result (poverty headcount/gini etc) is returned when this argument is TRUE
. I requested data for all countries with fill_gaps==TRUE
and got a returned dataframe with a variable isinterpolated
. It turns out that isinterpolated
is always 0
(indicates no interpolation), and the total amount of data is equal to that with fill_gaps==FALSE
.
Is there a mistake in this function or something I have misunderstood?
Really need the interpolated data (or methodology). Thanks in advance.
Should be pulled automatically from pocalnet_info cache, not from a separate object -> Risk of being out of sync
povcalnet_cl("ARG", 1.9, 1980)
will not return any data because coverage
is not specified, and the API only returns "national" coverage data by default.
TO DO:
Hey @tonyfujs ,
I just checked and the only name of the function arguments that need to be changed is poverty_line=
to pov_line=
. In Stata the option name is povline()
Thanks.
Best,
For example this works:
povcalnet_cl(rep("CHN",76),seq(0.01,0.76,0.01),rep(2010,76))
while this:
povcalnet_cl(rep("CHN",77),seq(0.01,0.77,0.01),rep(2010,77))
produces an error:
"Error: assert_that: assertion must return a logical value"
[using a fully updated R version 3.6.1 (2019-07-05) on Ubuntu 18.04.3 LTS]
povcalnet(country = "XXX", year = 2002)
throws an error. It should return a well formatted, empty data.frame
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.