Skip to content

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

@tphilippi

Description

@tphilippi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions