walkerke / tidycensus

Load US Census boundary and attribute data as 'tidyverse' and 'sf'-ready data frames in R
https://walker-data.com/tidycensus
Other
639 stars 100 forks source link

Error: Columns 1, 2, 3, 4, 5, … (and 2 more) must be named. #143

Closed abuabara closed 5 years ago

abuabara commented 5 years ago

I had some pieces of code that were pulling ACS 5Y Census data pretty well. Suddenly (starting yesterday), the codes have not worked anymore. At first I thought it was due to some package update (slang, tibble, etc.). But probably no, because I tested on machines that were off for a while and I get the same messages. I suspect it may be due to government shutdown, but I'm not sure either. Using the ACS package I have been able to download data. Any thoughts on that? Thanks a lot in advance!

PS. interestingly the tigris package is working well. I do not know if due to caches in my machine.

> data_BG <- get_acs(geography="block group",
+                    county="007",
+                    variables="B01001_002",
+                    geometry=T,
+                    state="48",
+                    year=2016)
Getting data from the 2012-2016 5-year ACS
Error: Columns 1, 2, 3, 4, 5, … (and 2 more) must be named.
Use .name_repair to specify repair.
Call `rlang::last_error()` to see a backtrace
mfherman commented 5 years ago

This looks like an error introduced with the new release of tibble that is addressed in #130. Try updating to the development version of tidycensus and this should be fixed:

devtools::install_github("walkerke/tidycensus")
abuabara commented 5 years ago

Thanks for the answer. I've tried this, but it still does not work. It must be something else.

mfherman commented 5 years ago

Hmm, I can't reproduce your error on my machine. Here is a reprex with the working code as well as my session info. Do you see package versions that differ between our configurations?

library(tidycensus)

get_acs(
  geography = "block group",
  county = "007",
  variables = "B01001_002",
  geometry = TRUE,
  state = "48",
  year = 2016
)
#> Getting data from the 2012-2016 5-year ACS
#> Simple feature collection with 19 features and 5 fields (with 1 geometry empty)
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -97.26082 ymin: 27.83954 xmax: -96.79053 ymax: 28.31923
#> epsg (SRID):    4269
#> proj4string:    +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
#> First 10 features:
#>           GEOID                                                    NAME
#> 1  480079501001 Block Group 1, Census Tract 9501, Aransas County, Texas
#> 2  480079501002 Block Group 2, Census Tract 9501, Aransas County, Texas
#> 3  480079501003 Block Group 3, Census Tract 9501, Aransas County, Texas
#> 4  480079501004 Block Group 4, Census Tract 9501, Aransas County, Texas
#> 5  480079501005 Block Group 5, Census Tract 9501, Aransas County, Texas
#> 6  480079502001 Block Group 1, Census Tract 9502, Aransas County, Texas
#> 7  480079502002 Block Group 2, Census Tract 9502, Aransas County, Texas
#> 8  480079503001 Block Group 1, Census Tract 9503, Aransas County, Texas
#> 9  480079503002 Block Group 2, Census Tract 9503, Aransas County, Texas
#> 10 480079503003 Block Group 3, Census Tract 9503, Aransas County, Texas
#>      variable estimate moe                       geometry
#> 1  B01001_002      613 202 MULTIPOLYGON (((-96.8229 28...
#> 2  B01001_002      926 304 MULTIPOLYGON (((-97.11207 2...
#> 3  B01001_002      763 230 MULTIPOLYGON (((-97.00868 2...
#> 4  B01001_002       97  68 MULTIPOLYGON (((-97.0415 28...
#> 5  B01001_002      179  77 MULTIPOLYGON (((-97.04129 2...
#> 6  B01001_002      202  55 MULTIPOLYGON (((-97.0341 28...
#> 7  B01001_002      417 148 MULTIPOLYGON (((-97.05207 2...
#> 8  B01001_002     1443 328 MULTIPOLYGON (((-97.07184 2...
#> 9  B01001_002      873 302 MULTIPOLYGON (((-97.05889 2...
#> 10 B01001_002      673 231 MULTIPOLYGON (((-97.08877 2...

Created on 2019-01-08 by the reprex package (v0.2.1)

Session info ``` r devtools::session_info() #> ─ Session info ────────────────────────────────────────────────────────── package * version date lib source assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.5.0) backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.0) callr 3.1.1 2018-12-21 [1] CRAN (R 3.5.0) class 7.3-15 2019-01-01 [1] CRAN (R 3.5.2) classInt 0.3-1 2018-12-18 [1] CRAN (R 3.5.0) cli 1.0.1 2018-09-25 [1] CRAN (R 3.5.1) clipr 0.4.1.9000 2018-10-24 [1] Github (mdlincoln/clipr@d39ee0d) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.0) curl 3.2 2018-03-28 [1] CRAN (R 3.5.0) DBI 1.0.0 2018-05-02 [1] CRAN (R 3.5.0) desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.0) devtools 2.0.1 2018-10-26 [1] CRAN (R 3.5.1) digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.0) dplyr 0.8.0.9000 2019-01-08 [1] Github (tidyverse/dplyr@1c474b5) e1071 1.7-0 2018-07-28 [1] CRAN (R 3.5.0) evaluate 0.12 2018-10-09 [1] CRAN (R 3.5.1) foreign 0.8-71 2018-07-20 [1] CRAN (R 3.5.2) fs 1.2.6 2018-08-23 [1] CRAN (R 3.5.0) glue 1.3.0 2018-07-17 [1] CRAN (R 3.5.0) hms 0.4.2.9001 2018-08-28 [1] Github (tidyverse/hms@979286f) htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.0) httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.1) jsonlite 1.6 2018-12-07 [1] CRAN (R 3.5.1) knitr 1.21 2018-12-10 [1] CRAN (R 3.5.1) lattice 0.20-38 2018-11-04 [1] CRAN (R 3.5.2) magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.0) maptools 0.9-4 2018-09-19 [1] CRAN (R 3.5.1) memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0) pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.0) pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.5.0) pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.1) pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.1) prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.0) processx 3.2.1 2018-12-05 [1] CRAN (R 3.5.1) ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.0) purrr 0.2.5 2018-05-29 [1] CRAN (R 3.5.0) R6 2.3.0 2018-10-04 [1] CRAN (R 3.5.1) rappdirs 0.3.1 2016-03-28 [1] CRAN (R 3.5.0) Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.5.0) readr 1.3.1 2018-12-21 [1] CRAN (R 3.5.0) remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.1) reprex 0.2.1 2018-09-16 [1] CRAN (R 3.5.1) rgdal 1.3-6 2018-10-16 [1] CRAN (R 3.5.0) rlang 0.3.1 2019-01-08 [1] CRAN (R 3.5.2) rmarkdown 1.11 2018-12-08 [1] CRAN (R 3.5.0) rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0) rstudioapi 0.8 2018-10-02 [1] CRAN (R 3.5.0) rvest 0.3.2 2016-06-17 [1] CRAN (R 3.5.0) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.0) sf 0.7-3 2019-01-08 [1] Github (r-spatial/sf@e933411) sp 1.3-1 2018-06-05 [1] CRAN (R 3.5.0) stringi 1.2.4 2018-07-20 [1] CRAN (R 3.5.0) stringr 1.3.1.9000 2019-01-08 [1] Github (tidyverse/stringr@cec6a66) testthat 2.0.1 2018-10-13 [1] CRAN (R 3.5.0) tibble 2.0.0 2019-01-04 [1] CRAN (R 3.5.2) tidycensus * 0.8.9 2019-01-08 [1] Github (walkerke/tidycensus@5e24d37) tidyr 0.8.2 2018-10-28 [1] CRAN (R 3.5.1) tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.1) tigris 0.7 2018-04-14 [1] CRAN (R 3.5.0) units 0.6-3 2019-01-08 [1] Github (r-quantities/units@6117b13) usethis 1.4.0 2018-08-14 [1] CRAN (R 3.5.0) uuid 0.1-2 2015-07-28 [1] CRAN (R 3.5.0) whisker 0.3-2 2013-04-28 [1] CRAN (R 3.5.0) withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0) xfun 0.4 2018-10-23 [1] CRAN (R 3.5.1) xml2 1.2.0 2018-01-24 [1] CRAN (R 3.5.0) ```
abuabara commented 5 years ago

THANK YOU! worked after updating my packages to dev versions (just followed yours). Not sure which one is making the difference ... just the tidycensus was not enough. Thanks again! ;)

library(devtools) devtools::install_github("mdlincoln/clipr") devtools::install_github("tidyverse/dplyr@rc_0.8.0") devtools::install_github("tidyverse/hms") devtools::install_github("r-spatial/sf") devtools::install_github("tidyverse/stringr") devtools::install_github("walkerke/tidycensus")

walkerke commented 5 years ago

@mfherman you're the best! I'm putting you down as a package contributor on the next CRAN release for answering so many user questions.

mfherman commented 5 years ago

Thanks @walkerke, glad to be of service!

josiekre commented 5 years ago

Looks like the key is having compatible tibble and tidycensus. I needed to update to tibble 2.0.1 and tidycensus to 0.9.0 for the error to go away. Update the Description to require 2.0.1 or greater for tibble?

josiekre commented 5 years ago

I take that back. I updated tidycensus to 0.9 in a Docker container without touching anything else, and it seems to be working. tibble is at 1.4.2. So something else different between these two machines is causing the error. Ugh.

mfherman commented 5 years ago

@josiekre if you are able to isolate which package/version is causing the error, let us know and we can take a look.

walkerke commented 5 years ago

Thanks @josiekre @mfherman - yes let's update the required dependency version once the problem is identified.

abiyug commented 5 years ago

Run into this issue. I think this issue is due to older R version. I run into the same issue with R version 3.3.2, but tidycensus from CRAN on R version 3.5.2 works without having to install the devtool version.

In the package description it says tidycensus "depends on R >= 3.3.0", this should be updated.

With constant version updates of dependencies and import pkgs, I think, including a tried/tested/recommended software comparability matrix in the documentation will help.