UrbanInstitute / education-data-package-r

https://urbaninstitute.github.io/education-data-package-r/
Other
86 stars 11 forks source link

Error in Rbind #72

Closed grahamimac closed 4 years ago

grahamimac commented 4 years ago

@khueyama Getting an error when running the following. I need to run this to check against a priority error I'm getting elsewhere in the portal to isolate it, so this is top priority for me. As soon as you can get to it the better. Thank you!

df <- get_education_data(level = 'schools', 
                          source = 'ccd', 
                          topic = 'enrollment', 
                          by = list('race'),
                          filters = list(year = 1993,
                                         grade = 99,
                                         sex = 99),
                          add_labels = FALSE)

Runs and all API calls execute (seems successfully). Then this error

Fetching data for schools/ccd/enrollment/1993/grade-99/race/?sex=99 ...
Processing page 2 out of 512
...
Processing page 511 out of 512
Processing page 512 out of 512
Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match

Session info:

R version 3.6.1 (2019-07-05)
Platform: [redacted - 64 bit]
Running under: [redacted - Windows 10]

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] educationdata_0.0.4 forcats_0.5.0       stringr_1.4.0       dplyr_0.8.5        
 [5] purrr_0.3.3         readr_1.3.1         tidyr_1.0.2         tibble_2.1.3       
 [9] ggplot2_3.3.0       tidyverse_1.3.0    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4        lubridate_1.7.4   lattice_0.20-38   prettyunits_1.1.1
 [5] ps_1.3.2          assertthat_0.2.1  rprojroot_1.3-2   digest_0.6.25    
 [9] R6_2.4.1          cellranger_1.1.0  backports_1.1.5   reprex_0.3.0     
[13] httr_1.4.1        pillar_1.4.3      rlang_0.4.5       curl_4.3         
[17] readxl_1.3.1      rstudioapi_0.11   callr_3.4.3       desc_1.2.0       
[21] devtools_2.2.2    munsell_0.5.0     broom_0.5.5       compiler_3.6.1   
[25] modelr_0.1.6      pkgconfig_2.0.3   pkgbuild_1.0.6    tidyselect_1.0.0 
[29] fansi_0.4.1       crayon_1.3.4      dbplyr_1.4.2      withr_2.1.2      
[33] grid_3.6.1        nlme_3.1-140      jsonlite_1.6.1    gtable_0.3.0     
[37] lifecycle_0.2.0   DBI_1.1.0         magrittr_1.5      scales_1.1.0     
[41] cli_2.0.2         stringi_1.4.6     fs_1.3.2          remotes_2.1.1    
[45] testthat_2.3.2    xml2_1.2.5        ellipsis_0.3.0    generics_0.0.2   
[49] vctrs_0.2.4       tools_3.6.1       glue_1.3.2        hms_0.5.3        
[53] processx_3.4.2    pkgload_1.0.2     colorspace_1.4-1  sessioninfo_1.1.1
[57] rvest_0.3.5       memoise_1.1.0     haven_2.2.0       usethis_1.5.1  
grahamimac commented 4 years ago

Note this could very well be the error I'm running into (e.g., columns aren't matching meaning the JSON doesn't have a consistent # of keys across the list), so would love to have you look into it on your end.

khueyama commented 4 years ago

Yes, this is almost certainly the same issue, but I will dive into a bit to try to give you some more context. Problem is this will occur at random times on the API back end, so nearly impossible to fully replicate. But with 512 pages maybe it's just good odds it will happen on at least one of them. If you check out the repo for the API itself you will see an issue from me that has some more detail on this behavior, albeit on a different endpoint.

grahamimac commented 4 years ago

I was able to replicate this across packages, so closing this here and moving discussion to your comment. No need to follow up on this further. Thanks Kyle.