第一次在stackoverflow提问。
我正在尝试通过 lodown R 包遵循有关 PNS (Pesquisa Nacional de Saúde) 的示例(书中的说明http://asdfree.com/)。我严格按照代码进行操作,但不断收到错误消息。这是我从 R 与 sessionInfo() 一起获得的代码和输出错误消息。有办法获取数据吗?我不明白收到的错误消息。
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
好吧,已经有一段时间了,但我要回答我自己的问题。我尝试联系 lodown 的维护者,但没有成功。与此同时,发布了一个非常好的包来从 IBGE 获取 PNS 数据。如果有人对此感兴趣,该软件包称为“PNSIBGE”。
install.packages("PNSIBGE")
你成功加载2013年的数据了吗?我只能加载 2019 年的 Wave,就像 2013 年一样,我得到“std::bad_alloc”