microdadosBrasil
microdadosBrasil copied to clipboard
Error when importing columns in CENSO 2010 dataset
Hello, I was testing out the package for the first time, and I encountered the following problem.
d <- read_CENSO(ft = "pessoas",
i = "2010",
source_file_mark = TRUE,
vars_subset = c("V0618", "V1006"))
Error in if (any(dic$decimal_places) & dataset == "CENSO") { :
missing value where TRUE/FALSE needed
Inspecting the error message, I realized that at some point, the logical test if (any(dic$decimal_places) & dataset == "CENSO")
encounters the dictionary where you can find missing values in the decimal_places column. As shown below:
int_pos var_name x label length decimal_places fin_pos col_type CHAR
1 1 V0001 NA NA 2 NA 2 c FALSE
2 3 V0002 NA NA 5 NA 7 c FALSE
3 8 V0011 NA NA 13 NA 20 c FALSE
4 21 V0300 NA NA 8 NA 28 d FALSE
5 29 V0010 NA NA 3 13 44 d FALSE
6 45 V1001 NA NA 1 NA 45 c TRUE
I imagine the problem can be solved by changing the if clause to return FALSE on missing values. Here is my sessionInfo()
in case it helps.
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
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] stats graphics grDevices utils datasets methods base
other attached packages:
[1] microdadosBrasil_0.0.0.9000
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 rstudioapi_0.10 magrittr_1.5 hms_0.5.1 tidyselect_0.2.5 R6_2.4.0
[7] rlang_0.4.1 stringr_1.4.0 dplyr_0.8.3 tools_3.6.1 data.table_1.12.6 assertthat_0.2.1
[13] tibble_2.1.3 crayon_1.3.4 purrr_0.3.3 readr_1.3.1 vctrs_0.2.0 bitops_1.0-6
[19] RCurl_1.95-4.12 zeallot_0.1.0 glue_1.3.1 stringi_1.4.3 compiler_3.6.1 pillar_1.4.2
[25] backports_1.1.5 pkgconfig_2.0.3