ajdamico / lodown

locally download and prepare publicly-available microdata
GNU General Public License v3.0
97 stars 47 forks source link

Issue with PNS data #178

Closed dcpcamara closed 8 months ago

dcpcamara commented 3 years ago

I'm trying to follow the examples regarding the PNS (Pesquisa Nacional de Saúde) via lodown R package (instructions in the book http://asdfree.com/). I'm following the presented code to the letter but I keep getting error messages. This is the code and output error message that I get from R together with my sessionInfo(). Is there a way to get the data? I don't understand the error message that I'm getting.

`

download the microdata to your local computer

pns_cat <- lodown("pns" , pns_cat) locally downloading pns

downloading from URL 'ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao' to file 'C:\Users\dcpca\AppData\Local\Temp\RtmpuO2Oba\file512c18947'

download issue with 'ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao'

download issue with 'ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao'

download issue with 'ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao'

R version 4.0.1 (2020-06-06) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale: [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252 [4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252

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

other attached packages: [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.3 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2
[7] tibble_3.0.5 ggplot2_3.3.3 tidyverse_1.3.0 SAScii_1.0 lodown_0.1.0 srvyr_1.0.0
[13] survey_4.0 survival_3.1-12 Matrix_1.2-18 data.table_1.13.6 devtools_2.3.2 usethis_2.0.0
[19] pacman_0.5.1

loaded via a namespace (and not attached): [1] Rcpp_1.0.6 lubridate_1.7.9.2 lattice_0.20-41 prettyunits_1.1.1 ps_1.5.0 digest_0.6.27
[7] assertthat_0.2.1 rprojroot_2.0.2 cellranger_1.1.0 R6_2.5.0 backports_1.2.0 reprex_1.0.0
[13] httr_1.4.2 pillar_1.4.7 rlang_0.4.10 curl_4.3 readxl_1.3.1 rstudioapi_0.13
[19] callr_3.5.1 desc_1.2.0 splines_4.0.1 RCurl_1.98-1.2 munsell_0.5.0 broom_0.7.4
[25] compiler_4.0.1 modelr_0.1.8 pkgconfig_2.0.3 pkgbuild_1.2.0 mitools_2.4 tidyselect_1.1.0 [31] crayon_1.4.0 dbplyr_2.0.0 withr_2.4.1 bitops_1.0-6 jsonlite_1.7.2 gtable_0.3.0
[37] lifecycle_0.2.0 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1 stringi_1.5.3 cli_2.3.0
[43] cachem_1.0.1 fs_1.5.0 remotes_2.2.0 testthat_3.0.1 xml2_1.3.2 ellipsis_0.3.1
[49] generics_0.1.0 vctrs_0.3.6 tools_4.0.1 glue_1.4.2 hms_1.0.0 processx_3.4.5
[55] pkgload_1.1.0 fastmap_1.1.0 colorspace_2.0-0 sessioninfo_1.1.1 rvest_0.3.6 memoise_2.0.0
[61] haven_2.3.1

lodown is now exiting unexpectedly. websites that host publicly-downloadable microdata change often and sometimes those changes cause this software to break. if the error call stack below appears to be a hiccup in your internet connection, then please verify your connectivity and retry the download. otherwise, please open a new issue at https://github.com/ajdamico/asdfree/issues with the contents of this error call stack and also the output of your sessionInfo().

[[1]] lodown("pns", pns_cat)

[[2]] withCallingHandlers(catalog <- load_fun(data_name = data_name, catalog, ...), error = function(e) { print(sessionInfo()) if (grepl("cannot allocate vector of size", e)) message(memory_note) else if (grepl("parameter must be specified", e)) message(parameter_note) else if (grepl("to install", e)) message(installation_note) else { message(unknown_error_note) print(sys.calls()) } })

[[3]] load_fun(data_name = data_name, catalog, ...)

[[4]] cachaca(catalog[i, "full_url"], tf, mode = "wb")

[[5]] httr_filesize(this_url, attempts, sleepsec)

[[6]] stop(paste0("httr::HEAD( '", url, "' )\nfailed after ", initial.attempts, " attempts"))

[[7]] .handleSimpleError(function (e) { print(sessionInfo()) if (grepl("cannot allocate vector of size", e)) message(memory_note) else if (grepl("parameter must be specified", e)) message(parameter_note) else if (grepl("to install", e)) message(installation_note) else { message(unknown_error_note) print(sys.calls()) } }, "httr::HEAD( 'ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao' )\nfailed after 3 attempts", base::quote(httr_filesize(this_url, attempts, sleepsec)))

[[8]] h(simpleError(msg, call))

Error in httr_filesize(this_url, attempts, sleepsec) : httr::HEAD( 'ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao' ) failed after 3 attempts year full_url 1 2019 ftp://ftp.ibge.gov.br/PNS/2019/Microdados/Documentacao 2 2013 ftp://ftp.ibge.gov.br/PNS/2013/Microdados/historico_atualizacao_microdados_PNS_2013_20200825.txt output_folder long_file all_file 1 C:/Users/dcpca/Documents/PNS/ 2019 long questionnaire survey.rds 2019 all questionnaire survey.rds 2 C:/Users/dcpca/Documents/PNS/ 2013 long questionnaire survey.rds 2013 all questionnaire survey.rds long_design all_design case_count 1 2019 long questionnaire survey design.rds 2019 all questionnaire survey design.rds NA 2 2013 long questionnaire survey design.rds 2013 all questionnaire survey design.rds NA `

ajdamico commented 8 months ago

oi Daniel! apologies for the long delay. i've made a couple of big updates to asdfree.com that hopefully make the website a bit better, but i've decided to stop maintaining the lodown package so probably won't fix the bug you've reported. the new asdfree does have pns data, but only for the most current year. thanks