Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_flows() at the county level #486

Closed
Arthur-Langlois opened this issue Dec 1, 2022 · 1 comment
Closed

get_flows() at the county level #486

Arthur-Langlois opened this issue Dec 1, 2022 · 1 comment

Comments

@Arthur-Langlois
Copy link

Hi I am trying to do a simple pull of all county-level migration flows but keep getting the following error:

library(tidycensus)
library(tidyverse)
library(tigris)
library(sf)
library(glue)

API_KEY_CENSUS <- 'xyz'
census_api_key(API_KEY_CENSUS)

b <- data.frame(get_flows(geography = "county",
                          year = 2013,
                          geometry = FALSE))
Error: Your API call has errors.  The API message returned is error: wildcard not allowed for 'state' in geography heirarchy.

The documentation says that county level migration is available, and checked this issue, but without success.
Thanks!

@walkerke
Copy link
Owner

walkerke commented Dec 2, 2022

It appears the ability to pull migration flows for all counties like that starts with the 2012-2016 ACS. In your case, you would need to iterate through all the states and combine. For example:

library(tidycensus)
library(tidyverse)

state_codes <- c(state.abb, "DC")

all_flows <- map_dfr(state_codes, ~{
  get_flows(
    geography = "county",
    state = .x,
    year = 2013
  )
})

@walkerke walkerke closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants