icd
icd copied to clipboard
Fails to download who16?
download_all_icd_data()
Not all available data is currently downloaded. You may use: ‘download_all_icd_data()’ to complete downloading all available data, or let this happen on demand.
Using ‘[my homedir]cache/R/icd’ for saving ICD data.
Downloading, caching and parsing all ICD data
This will take a few minutes, and use about 340MB.
Working on: icd9cm2014_leaf
Working on: icd10cm2019
Working on: icd10who2016
Error : Argument 'txt' must be a JSON string, URL or file.
Working on: icd10who2008fr
Error : Argument 'txt' must be a JSON string, URL or file.
Working on: icd10fr2019
Error in utils::unzip(zipfile, exdir = zipdir) :
(converted from warning) error 1 in extracting from zip file
Working on: icd10be2014
Downloading icd10be2014 data
Working on: icd10be2014_pc
Working on: icd10be2017
Downloading icd10be2017 data
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to www.health.belgium.be:443
Error in utils::download.file(url = url, destfile = save_path, quiet = TRUE, :
'curl' call had nonzero exit status
Working on: icd10be2017_pc
Working on: icd9cm2005_leaf
[more successful ones]...
Seems like a few URL:s aren't working.
Hi Hans,
I have also had this issue, but believe I have found the cause for some of the errors thrown.
Given the icd package is currently not available on the CRAN respository, I downloaded the most recent version of icd (4.0.9) available from the CRAN archive and installed from source. When running download_all_icd_data(), I encountered the same errors as yourself.
Upon debugging, it appears the error in accessing WHO 2016 is due to a line in the who.R file (which Jack has already fixed here: https://github.com/jackwasey/icd/commit/450126c54a5d40a1cd0cb1a2448436a6ccacae18)
json_data <- httr::content(http_response, simplifyDataFrame=TRUE)
To the best of my understanding, json_data was not a valid JSON object for manipulation in the next call, resulting in the error 'Error : Argument 'txt' must be a JSON string, URL or file.'.
The following code which Jack has written, however, does provide a fix:
# encoding not specified by WHO resource (as of 2020-06-06). Be explicit
# about assumption.
json_data <- httr::content(http_response, type = "text", encoding = "UTF-8")
The method I used to edit is as follows:
- Call
options(error=recover)
. This call assists with stepping through the function causing the problem. - Call
get_icd10who2016()
. - Select option 9 (i.e. .dl_icd10who_json(year, lang, resource)).
- Call
trace(.dl_icd10who_json, edit = TRUE)
. - In the popup, find the error line from above and replace it with
json_data <- httr::content(http_response, type = "text", encoding = "UTF-8")
and save. - Press Esc.
- Exit recover mode by calling
options(error=NULL)
.
It appears that this has fixed my problem.
For anyone reading this -- if this method of amending a package that I have used above is not the best way to do so, I would appreciate if you could tell me a better way! I'm relatively new to R, and working with packages is very new to me.
Kind regards, N