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>
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!
Created on 2021-11-18 by the reprex package (v2.0.0)