mountainMath / cancensus

R wrapper for calling CensusMapper APIs
https://mountainmath.github.io/cancensus/index.html
Other
82 stars 15 forks source link

Setting up dev branch for update to 0.3 #147

Closed dshkol closed 4 years ago

dshkol commented 4 years ago

Merging in the two branches with changes from dplyr-deprecated and better-search

dshkol commented 4 years ago

I added a manual workaround to return the Census Agglomeration level for list_census_regions(dataset). Does it require a similar hack on the get_census... side when sending up regions, like we discussed the other day?

Touched up a bit of the documentation but will need a bit more work when everything is ready.

There is an error in the taxfiler vignette in this chunk.

ggplot(plot_data,aes(fill=share)) +
  geom_sf(size=0.1,color="white") +
  facet_wrap("Year") +
  scale_fill_viridis_c(labels=scales::percent,option = "inferno",
                       trans="log",breaks = c(0.05,0.1,0.2,0.4)) +
  coord_sf(datum=NA,xlim=c(-123.4, -122.5), ylim=c(49.01, 49.4)) +
  labs(title="Share of census families in low income",fill="Share",
       caption=attribution)
Error in as.name(geometry_col) : invalid type/length (symbol/0) in vector allocation
mountainMath commented 4 years ago

Will have a look today. One issue with the CA level is that censusmapper treats CAs and CMAs as interchangeable internally. It basically makes no difference if you specify CA or CMA. So if you ask for CMA level for BC, you can all CMAs and CAs in BC. Same if you specify CA.

mountainMath commented 4 years ago

I did not have an issue with the tax data vignette, but it broke on the cancensus.rmd because one of the find_census_vectors asked for user interaction. I added the "interaction=FALSE" in the call and it seems to compile through fine now.

mountainMath commented 4 years ago

One other question I have is around the pre-compiled vignettes. And maybe adding \dontrun{} for the examples. Right now (I think) we hit the CensusMapper server for calls that don't require an API key. But if I update the server with downtime it might trigger the CRAN mess that we had with {cansim}. So far we did not have problems, but something to consider.

dshkol commented 4 years ago

Will have a look today. One issue with the CA level is that censusmapper treats CAs and CMAs as interchangeable internally. It basically makes no difference if you specify CA or CMA. So if you ask for CMA level for BC, you can all CMAs and CAs in BC. Same if you specify CA.

I just want to avoid us being imprecise when displaying these classifications, at least in the list_census_regions call. Would it be improperly label CAs as CMAs anywhere else?

dshkol commented 4 years ago

One other question I have is around the pre-compiled vignettes. And maybe adding \dontrun{} for the examples. Right now (I think) we hit the CensusMapper server for calls that don't require an API key. But if I update the server with downtime it might trigger the CRAN mess that we had with {cansim}. So far we did not have problems, but something to consider.

Let's save that for the end. I understand the risk, but are you planning significant downtime in the near future?

mountainMath commented 4 years ago

I think it’s probably fine. Most people will hand-pick CMAs or CAs anyway instead of grabbing all CMAs in a province or in the country.

Alternatively I can re-rig things server side to treat down CMAs and CAs separately. Maybe that’s the best solution.

dshkol commented 4 years ago

I did not have an issue with the tax data vignette, but it broke on the cancensus.rmd because one of the find_census_vectors asked for user interaction. I added the "interaction=FALSE" in the call and it seems to compile through fine now.

I'm still getting this error, clean session, clean pull from your last commit.

Quitting from lines 86-94 (Taxfiler_Data.Rmd) 
* Error in as.name(geometry_col) : 
*   invalid type/length (symbol/0) in vector allocation
* In addition: Warning messages:
* 1: In (function (x, na.strings = "NA")  : NAs introduced by coercion
* 2: In bind_rows_(x, .id) :
*   Vectorizing 'sfc_MULTIPOLYGON' elements may not preserve their attributes
* 3: In bind_rows_(x, .id) :
*   Vectorizing 'sfc_MULTIPOLYGON' elements may not preserve their attributes
* 4: In bind_rows_(x, .id) :
*   Vectorizing 'sfc_MULTIPOLYGON' elements may not preserve their attributes
* 5: In bind_rows_(x, .id) :
*   Vectorizing 'sfc_MULTIPOLYGON' elements may not preserve their attributes

Can you do a sessionInfo?

mountainMath commented 4 years ago
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
[1] sf_0.9-4        ggplot2_3.3.1   tidyr_1.1.0     dplyr_1.0.0     cancensus_0.2.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6       pillar_1.4.4       compiler_4.0.0     class_7.3-17       tools_4.0.0        digest_0.6.25     
 [7] packrat_0.5.0      viridisLite_0.3.0  jsonlite_1.6.1     lifecycle_0.2.0    tibble_3.0.1       gtable_0.3.0      
[13] pkgconfig_2.0.3    rlang_0.4.6        DBI_1.1.0          rstudioapi_0.11    curl_4.3           xfun_0.14         
[19] e1071_1.7-3        withr_2.2.0        httr_1.4.1         knitr_1.28         generics_0.0.2     vctrs_0.3.1       
[25] hms_0.5.3          classInt_0.4-3     grid_4.0.0         tidyselect_1.1.0   glue_1.4.1         geojsonsf_1.3.3   
[31] R6_2.4.1           farver_2.0.3       purrr_0.3.4        readr_1.3.1        magrittr_1.5       scales_1.1.1      
[37] ellipsis_0.3.1     units_0.6-7        colorspace_1.4-1   labeling_0.3       KernSmooth_2.23-17 munsell_0.5.0     
[43] crayon_1.3.4  
dshkol commented 4 years ago

I have

other attached packages:
[1] sf_0.9-3        ggplot2_3.3.0   tidyr_1.0.3     dplyr_0.8.5     cancensus_0.2.2

loaded via a namespace (and not attached):
 [1] tidyselect_1.0.0   xfun_0.13          remotes_2.1.1      rematch2_2.1.2     purrr_0.3.4        colorspace_1.4-1   vctrs_0.2.4       
 [8] testthat_2.3.2     usethis_1.6.1      htmltools_0.4.0    yaml_2.2.1         rlang_0.4.6        pkgbuild_1.0.8     e1071_1.7-3       
[15] pkgdown_1.5.1      pillar_1.4.4       glue_1.4.0         withr_2.2.0        DBI_1.1.0          sessioninfo_1.1.1  lifecycle_0.2.0   
[22] munsell_0.5.0      gtable_0.3.0       devtools_2.3.0     memoise_1.1.0      evaluate_0.14      knitr_1.28         callr_3.4.3       
[29] ps_1.3.3           class_7.3-16       curl_4.3           fansi_0.4.1        Rcpp_1.0.4.6       KernSmooth_2.23-16 backports_1.1.6   
[36] scales_1.1.0       classInt_0.4-3     desc_1.2.0         pkgload_1.0.2      fs_1.4.1           packrat_0.5.0      digest_0.6.25     
[43] processx_3.4.2     rprojroot_1.3-2    grid_4.0.0         cli_2.0.2          tools_4.0.0        magrittr_1.5       tibble_3.0.1      
[50] crayon_1.3.4       pkgconfig_2.0.3    MASS_7.3-51.6      ellipsis_0.3.0     prettyunits_1.1.1  assertthat_0.2.1   rmarkdown_2.1     
[57] httr_1.4.1         rstudioapi_0.11    R6_2.4.1           units_0.6-6        compiler_4.0.0