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

clarify parameter definitions for roads() state only length 1 county can have length > 1 #192

Open
tphilippi opened this issue Dec 15, 2024 · 0 comments

Comments

@tphilippi
Copy link

Could you perhaps reword the documentation for the roads() function to clarify that only a single value is allowed for the state parameter, but a vector of values is supported for the county parameter?

Based on the documentation calling both the state and county parameters vectors, I attempted to request 3 counties in 2 states:
myroads <- tigris::roads(state = c("28", "28", "22"), county = c("149", "049", "065"))
That throws an error because the grepl condition has length > 1. Inspection of the code shows that roads() only handles a single value for state.

My use case shouldn't be unique: I have an AoA I need to download roads for; I use:

counties <- tigris::counties(cb = TRUE)
needCty <- sf::st_intersection(counties, AoA)

The obvious next line would be:

rd <- tigris::roads(needCty$STATEFP, needCty$COUNTYFP)

which fails when my AoA intersects 2 states.

I don't think it's worth changing roads() to support multiple states; that can be handled via dplyr as long as users know they have to call 1 state at a time (& I can give you a short example of that code).

My requested edit is in bold:

#' @param state A character vector of length 1 of the two-digit FIPS code of the state of the county
#' you'd like to download the roads for. Can also be state name or abbreviation
#' (case-insensitive).
#' @param county A character vector of the three-digit FIPS code of the county or counties you'd like
#' the roads for. Can also be a vector of county names.

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

1 participant