-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Unable to download indicators - worked fine the day before #35
Comments
This problem also affects other packages that rely on the API (see: gshs-ornl/wbstats#23). Hence, I also assume that it is an issue with the World Bank API. Hopefully, it can be fixed easily. |
Let's hope for the best 🤞😊 Thanks for your quick reply! |
The world bank website appears to be down or not serving the data anymore. For example, this link is taken straight from their documentation but it doesn't work: http://api.worldbank.org/v2/country/br?format=json This happens from time to time. Usually gets fixed pretty quickly. |
The issue is that ALL the api calls now need the /v2/ embedded in them. Many of the api calls in the code still do not have that so they fail. I just did a code pull and verified that when I changed the ones without /v2/ to include it they did work. If those are updated I think all should be fine. |
Ohh except for this one apparently : |
Thanks a lot for digging in @dscrimager ! Turns out the api calls you identified without the "v2" weren't culprits. Notice that they are only in the I found what I think is a solution and I pushed it to Github, along with a new test suite. The tests pass. Could @dennis-hammerschmidt, @FabianFox and @dscrimager install the Github master and give it a try? If it works, I'll push to CRAN very very soon. Thanks! library(remotes)
install_github('vincentarelbundock/WDI')
library(WDI)
dataSeries = c("DT.DOD.DECT.GN.ZS",
"DT.DOD.DECT.EX.ZS",
"DT.TDS.DECT.EX.ZS")
dat <- WDI(indicator = dataSeries, country = 'all', start = 1990, end = 2020)
dat <- na.omit(dat)
head(dat)
#> iso2c country year DT.DOD.DECT.GN.ZS
#> 61 4E East Asia & Pacific (excluding high income) 1990 35.65028
#> 62 4E East Asia & Pacific (excluding high income) 1991 37.16875
#> 63 4E East Asia & Pacific (excluding high income) 1992 37.17847
#> 64 4E East Asia & Pacific (excluding high income) 1993 37.44126
#> 65 4E East Asia & Pacific (excluding high income) 1994 36.03527
#> 66 4E East Asia & Pacific (excluding high income) 1995 35.03725
#> DT.DOD.DECT.EX.ZS DT.TDS.DECT.EX.ZS
#> 61 153.4848 18.89601
#> 62 150.2238 17.69950
#> 63 141.9283 16.80542
#> 64 141.6803 17.43847
#> 65 131.9295 14.74167
#> 66 127.6825 14.19330 Created on 2020-06-21 by the reprex package (v0.3.0) |
Weird - I just hammered a /v2/ everywhere I saw a url and then sourced it into my code and it worked. Admittedly, I have a demo tomorrow in front of 50 students that suddenly didn't work so I was a bit frantic to figure out how to get it going any way possible... I didn't grok the code as I should before I shot from the hip. I'll try it now. |
I cannot get it to work - I deleted and re-added the JSON library. When I change this file and source it it works fine. I'm not expert enough with R packaging to know whats going on.
|
Wow, @dscrimager, that's really weird. I added Travis and Appveyor tests, and everything passes on Windows and Linux (and my own machine is a Mac). Since you've sourced some files, could you try:
|
BTW, I'm pretty sure you didn't install the new version of |
OK, confirmed. Not sure why I was not getting the new one - it reported it was installing it. Sorry to have steered you wrong. Anyhow : Ran all tests and they passed on my 3.6.1 ! |
I've followed the steps above but still get an error when applying it to my own function I mentioned in the beginning. Now it reads:
Since this error is different from before, I guess I'm on the most recent version (as it was also installed using I've also tried to run your test suite and get the following error for the first testthat
When I re-installed WDI from github and re-ran the testthat suite once again, I no longer receive this error and all tests pass. The error above for my own function, however, still persists. Similar to @dscrimager I'm using R 3.6.1 and am on a Mac OS Catalina (10.15.4). a) to c) in the error suggestions hold as I've not changed anything in my function to when it was working last week. I'm not sure where I find information on the status of the WDI servers, though. |
@dennis-hammerschmidt That's very weird. It works on my computer: library(WDI)
dataSeries <- c("DT.DOD.DECT.GN.ZS",
"DT.DOD.DECT.EX.ZS",
"DT.TDS.DECT.EX.ZS")
dat <- WDI(indicator = dataSeries, country = 'all', start = 1960, end = 2020)
tail(dat)
#> iso2c country year DT.DOD.DECT.GN.ZS DT.DOD.DECT.EX.ZS DT.TDS.DECT.EX.ZS
#> 15970 ZW Zimbabwe 2015 52.16885 224.6833 15.76324
#> 15971 ZW Zimbabwe 2016 59.78537 262.2356 28.83375
#> 15972 ZW Zimbabwe 2017 58.09882 244.9491 14.28684
#> 15973 ZW Zimbabwe 2018 39.80752 238.6148 11.70750
#> 15974 ZW Zimbabwe 2019 NA NA NA
#> 15975 ZW Zimbabwe 2020 NA NA NA Created on 2020-06-22 by the reprex package (v0.3.0) Is this exactly the code you are running? Also, the library(remotes)
remove.packages(c('RJSONIO', 'WDI'))
install_github('vincentarelbundock/WDI')
library(WDI)
WDI(indicator = 'DT.DOD.DECT.GN.ZS', country = 'all', start = 1960, end = 2020) |
Running your code for For now, I'm using the work-around of downloading the information for all countries and merging it with my own list of countries which effectively does the same thing as supplying my own list of countries. I'm finalizing a project at the moment where this solution is sufficient but I will take a look at this in more detail toward the end of the week to see if there are some countries beyond the ones that were flagged that might cause the problem. Until then, thank you so much for your help, I really appreciate it! :) |
Very weird. If you ever find out what the problem is let me know. For what it's worth, this code works on my machine: library(WDI)
dataSeries <- c("DT.DOD.DECT.GN.ZS",
"DT.DOD.DECT.EX.ZS",
"DT.TDS.DECT.EX.ZS")
countries <- c('YEM', 'DZA', 'USA', 'FRA')
dat <- WDI(indicator = dataSeries, country = countries,
start = 1960, end = 2020)
tail(dat)
#> iso2c country year DT.DOD.DECT.GN.ZS DT.DOD.DECT.EX.ZS
#> 237 YE Yemen, Rep. 2015 17.68016 386.1902
#> 238 YE Yemen, Rep. 2016 22.85435 738.1637
#> 239 YE Yemen, Rep. 2017 26.85555 NA
#> 240 YE Yemen, Rep. 2018 26.14523 NA
#> 241 YE Yemen, Rep. 2019 NA NA
#> 242 YE Yemen, Rep. 2020 NA NA
#> DT.TDS.DECT.EX.ZS
#> 237 18.94454
#> 238 14.56294
#> 239 NA
#> 240 NA
#> 241 NA
#> 242 NA
unique(dat$country)
#> [1] "Algeria" "France" "United States" "Yemen, Rep." Created on 2020-06-22 by the reprex package (v0.3.0) |
In case it's of use, I had similar problems over the past week, starting here with the World Bank API's SSL cert expiring. Then a week later, v1 of the API seems to have been decommissioned. Two major events in the space of a week! To solve for the SSL cert, I gsub'd the whole repo replacing All of the API calls were able to be converted by inserting |
Thanks @stevecondylios In the end, that's basically what I did to fix the problem.
|
A version with the emergency fix is now up on CRAN so I'll close this issue. In a few days I'll push a new version with more tests, input checks, and informative error messages. |
@vincentarelbundock I have a similar issue with WDI. Last time, I was able to fix it by following your recommendation: remove.packages("WDI") Today, I was trying again to work on my project and it throws an error again: In open.connection(con, "rb") : Is there anything else I can do to fix the code? |
My guess is that the World Bank server is down. Let me know if it still doesn’t work in a couple weeks.
|
Hi Vincent,
I have written the following small function to get a few indicators from the WDI dataset:
and I executed it for a list of countries for 2018 yesterday, all worked fine. Today, I now get the following error message:
Literally yesterday, all worked fine (except for the missing countries ATA, ESH, GUF, RKS, of course).
My question is if anything has changed in the API settings that you're aware of or that this is a problem that occurs when no connection to the API could be established. I see from your repo that there was no change in your code so I suspect that it might be something on the WDI side.
The text was updated successfully, but these errors were encountered: