Я пытаюсь получить геометрию из tidycensus
, но продолжаю сталкиваться с ошибками.
Я ввожу следующий код:
### Load packages
library(tidycensus)
library(dplyr)
library(tidyverse)
### Install api key
census_api_key("<mykey>")
### Pull data
cook<-get_acs(geography = "tract",variables = c(medincome = "B06011_001"),year=2018,survey = "acs5",state = "IL",
county = "Cook",geometry = T)
Но я получаю следующие выходные данные и ошибку:
Getting data from the 2014-2018 5-year ACS
Using FIPS code '17' for state 'IL'
Using FIPS code '031' for 'Cook County'
Error: All columns in a tibble must be vectors.
x Column `geometry` is a `sfc_MULTIPOLYGON/sfc` object.
Run `rlang::last_error()` to see where the error occurred.
Я следую подсказке и запускаю rlang::last_error()
и получаю:
<error/tibble_error_column_scalar_type>
All columns in a tibble must be vectors.
x Column `geometry` is a `sfc_MULTIPOLYGON/sfc` object.
Backtrace:
1. tidycensus::get_acs(...)
9. dplyr:::right_join.data.frame(geom, dat2, by = "GEOID")
12. dplyr::tbl_df(x)
14. tibble:::as_tibble.data.frame(data, .name_repair = "check_unique")
15. tibble:::lst_to_tibble(unclass(x), .rows, .name_repair)
16. tibble:::check_valid_cols(x)
Run `rlang::last_trace()` to see the full context.
Я следую подсказке и запускаю rlang::last_trace()
и получаю:
<error/tibble_error_column_scalar_type>
All columns in a tibble must be vectors.
x Column `geometry` is a `sfc_MULTIPOLYGON/sfc` object.
Backtrace:
x
1. \-tidycensus::get_acs(...)
2. +-right_join(geom, dat2, by = "GEOID") %>% st_as_sf()
3. | \-base::eval(lhs, parent, parent)
4. | \-base::eval(lhs, parent, parent)
5. +-dplyr::right_join(geom, dat2, by = "GEOID")
6. +-sf:::right_join.sf(geom, dat2, by = "GEOID")
7. | \-sf:::sf_join(NextMethod(), attr(x, "sf_column"))
8. +-base::NextMethod()
9. \-dplyr:::right_join.data.frame(geom, dat2, by = "GEOID")
10. +-base::as.data.frame(...)
11. +-dplyr::right_join(tbl_df(x), y, by = by, copy = copy, ...)
12. \-dplyr::tbl_df(x)
13. +-tibble::as_tibble(data, .name_repair = "check_unique")
14. \-tibble:::as_tibble.data.frame(data, .name_repair = "check_unique")
15. \-tibble:::lst_to_tibble(unclass(x), .rows, .name_repair)
16. \-tibble:::check_valid_cols(x)
Функция get_acs()
отлично работает при geometry=F
. Я не уверен, где go отсюда. Есть идеи?