Skip to content
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 downloading GR and NR datasets #151

Open
hallieeilerts opened this issue Apr 17, 2024 · 5 comments
Open

error downloading GR and NR datasets #151

hallieeilerts opened this issue Apr 17, 2024 · 5 comments

Comments

@hallieeilerts
Copy link

Hi Jeff and OJ!
Hope you are both well. I’ve recently been trying to use rdhs to download the Pregnancies Recode (GR) and Pregnancy and Postnatal Care Recode (NR) datasets from DHS 8 surveys and had a little trouble. I have approval to download these and can do so directly from the Survey Datasets Files page on DHS website (e.g., https://dhsprogram.com/data/dataset/Burkina-Faso_Standard-DHS_2021.cfm?flag=1).
However, when I run the below R code I get an error. Any ideas? Thanks!
-Hallie

Session Info
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.14.8 rdhs_0.8.1       

loaded via a namespace (and not attached):
 [1] httr_1.4.7      getPass_0.2-2   compiler_4.2.2  magrittr_2.0.3  R6_2.5.1        cli_3.6.1       tools_4.2.2     rstudioapi_0.14
 [9] curl_5.0.0      rappdirs_0.3.3  digest_0.6.31   jsonlite_1.8.4  brio_1.1.3      storr_1.2.5     rlang_1.1.0    
Reproducible example
set_rdhs_config(email = "XXXX",
                password_prompt =  TRUE,
                project = "XXXXX", 
                config_path = "rdhs.json",
                global=FALSE)

Sys.setenv("rdhs_RENVIRON_PERMISSION"=1)
Sys.setenv(rdhs_DATA_TABLE = "TRUE")
countries <- dhs_countries()

# vector with countries of interest
cc <- c("BF")

# Information on available surveys
surveys <- dhs_surveys(countryIds = cc, surveyYearStart=1980, surveyType = "DHS")

# Information on survey modules
# Pregnancies Recode 
nr_meta <- dhs_datasets(fileType = "NR", fileFormat = "flat")

# Identify modules of interest corresponding to surveys of interest
nrd <- nr_meta[which(nr_meta$SurveyId %in% surveys$SurveyId),]

nrd$path <- unlist(get_datasets(nrd$FileName))
Error message
These requested datasets are not available from your DHS login credentials:
---
BFNR81FL.ZIP
---
Please request permission for these datasets from the DHS website to be able to download them
@jeffeaton
Copy link
Collaborator

Hi @hallieeilerts -- great to hear from you!

Hmmm, I am not able to reproduce this; they have downloaded okay for me:

> get_datasets("BFNR81FL.ZIP")
Downloading: 
Burkina Faso 2021 DHS Pregnancy and Postnatal Care Recode Flat ASCII data (.dat) [BFNR81FL.ZIP]
Logging into DHS website...
Dataset download finished
$BFNR81FL
[1] "~/Library/Caches/rdhs/datasets/BFNR81FL.rds"

attr(,"reformat")
[1] FALSE

> get_datasets("BFSR81FL.ZIP")
Downloading: 
Burkina Faso 2021 DHS Siblings Recode Flat ASCII data (.dat) [BFSR81FL.ZIP]
Dataset download finished
$BFSR81FL
[1] "~/Library/Caches/rdhs/datasets/BFSR81FL.rds"

attr(,"reformat")
[1] FALSE

> get_datasets("BFGR81FL.ZIP")
Downloading: 
Burkina Faso 2021 DHS Pregnancies Recode Flat ASCII data (.dat) [BFGR81FL.ZIP]
Dataset download finished
$BFGR81FL
[1] "~/Library/Caches/rdhs/datasets/BFGR81FL.rds"

attr(,"reformat")
[1] FALSE

Can you try downloading just something like the IR dataset for that survey to check it's not an access issue?

get_datasets("BFIR81FL.ZIP")

@hallieeilerts
Copy link
Author

Hmm, no problem downloading the IR dataset. Just checked all the others, and also no problem with BR, CR, HR, MR, and PR. Access denied for FW, SR, NR, and GR. Can download all directly from the DHS website though. So strange...

@jeffeaton
Copy link
Collaborator

Can you try with clear_cache = TRUE to recreate the download URL list?

get_datasets("BFNR81FL.ZIP", clear_cache = TRUE)

@hallieeilerts
Copy link
Author

Just tried-- same error as above about the dataset not being available from my DHS login credentials.

@OJWatson
Copy link
Collaborator

Hmmm strange. Let me have a look at this and get back to you. And thanks for the great code example - really appreciate it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants