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_fars_crashes() returns error when county name is not unique #1

Closed
tiernanmartin opened this issue Nov 18, 2021 · 1 comment
Closed

Comments

@tiernanmartin
Copy link

Thanks for developing this package!

I ran into an unexpected error when I was trying to pull crash-by-location data for Washington state. A little debugging led me to believe it may be related to the county name argument--specifically, when the county name is present in multiple states.

Reprex below.

Cheers!

# common county names return an error:

crashapi::get_fars_crashes(state = "WA", county = "Adams")
#> Error in file(path): invalid 'description' argument

crashapi::get_fars_crashes(state = "WA", county = "King")
#> Error in file(path): invalid 'description' argument


# however, unique county names do not:

tibble::as_tibble(crashapi::get_fars_crashes(state = "WA", county = "Yakima"))
#> # A tibble: 63 x 15
#>    CITY  CITYNAME   COUNTY COUNTYNAME  CaseYear FATALS LATITUDE  LONGITUD  STATE
#>    <chr> <chr>      <chr>  <chr>       <chr>    <chr>  <chr>     <chr>     <chr>
#>  1 0     NOT APPLI~ 77     YAKIMA (77) 2015     1      46.72518~ -120.402~ 53   
#>  2 0     NOT APPLI~ 77     YAKIMA (77) 2015     1      46.51380~ -120.453~ 53   
#>  3 0     NOT APPLI~ 77     YAKIMA (77) 2015     1      46.39471~ -119.952~ 53   
#>  4 0     NOT APPLI~ 77     YAKIMA (77) 2014     1      46.34545~ -119.997~ 53   
#>  5 0     NOT APPLI~ 77     YAKIMA (77) 2015     1      46.39013~ -120.480~ 53   
#>  6 0     NOT APPLI~ 77     YAKIMA (77) 2014     1      46.32839~ -120.461~ 53   
#>  7 0     NOT APPLI~ 77     YAKIMA (77) 2014     1      46.34619~ -119.964~ 53   
#>  8 0     NOT APPLI~ 77     YAKIMA (77) 2015     1      46.41827~ -120.290~ 53   
#>  9 0     NOT APPLI~ 77     YAKIMA (77) 2014     1      46.38698~ -120.669~ 53   
#> 10 0     NOT APPLI~ 77     YAKIMA (77) 2015     1      46.43367~ -120.479~ 53   
#> # ... with 53 more rows, and 6 more variables: STATENAME <chr>, ST_CASE <chr>,
#> #   TOTALVEHICLES <chr>, TWAY_ID <chr>, TWAY_ID2 <chr>, VE_FORMS <chr>

Created on 2021-11-18 by the reprex package (v2.0.0)

elipousson added a commit that referenced this issue Nov 24, 2021
- fix #1  by allowing partial county names, e.g. "Adams" instead of "Adams County"
- feat: `get_fars_crash_details()` updated to support geometry parameter

fix: Correct capitalization of "city" in `county_to_fips()`
@elipousson
Copy link
Owner

Thanks for the catch! I updated the county_to_fips() function and (I think) fixed the issue.

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