get_fars | R Documentation |
This function provides a convenient interface for accessing FARS
data or data summaries using a range of criteria. The api
parameter
allows you to call one of the following functions to access DOT NHTSA’s
Crash API:
get_fars_crash_list
returns a list of fatal crashes that have occurred
in multiple states in one or more years.
get_fars_crash_details
returns a details of a fatal crash that has
occurred in a state for a single year.
get_fars_crashes
a list of fatal crashes by location that have occurred
throughout U.S.
get_fars_summary
provides a count of injury severity that have occurred
throughout U.S. including count of fatalities and crashes.
get_fars_year
provides one of 20 FARS data tables for a single year.
Supports downloading to a CSV or JSON file.
Both get_fars_crash_list
and get_fars_crashes
limit the returned data
to 5000 records so consider limiting the range of years requested if data
exceeds that threshold.
This package also enables access to the FARS data available through the
NHTSA data downloads server in a zip format. Set api
to "zip" or use the
get_fars_zip
function to download this data.
get_fars(
year = 2022,
state,
county = NULL,
api = c("crashes", "cases", "state list", "summary count", "year dataset", "zip"),
type = NULL,
details = FALSE,
geometry = FALSE,
crs = NULL,
cases = NULL,
vehicles = NULL,
format = "json",
pr = FALSE,
path = NULL,
download = FALSE
)
get_fars_crashes(
year = 2022,
start_year,
end_year = NULL,
state,
county,
details = FALSE,
geometry = FALSE,
crs = NULL
)
get_fars_cases(
year = 2022,
state,
cases,
details = FALSE,
geometry = FALSE,
crs = NULL
)
get_fars_crash_list(
year = 2022,
start_year = NULL,
end_year = NULL,
state,
vehicles = c(1, 50)
)
get_fars_summary(year = 2022, start_year, end_year = NULL, state)
get_fars_year(
year = 2022,
type = "accident",
state,
format = "json",
path = NULL,
geometry = FALSE,
crs = NULL,
download = FALSE
)
year |
numeric vector. Year or range with start and end year. If |
state |
Required. State name, abbreviation, or FIPS number.
|
county |
County name or FIPS number. Required for |
api |
character. API function to use. Supported values include "crashes", "cases", "state list", "summary count", "year dataset", and "zip". Default: "crashes". |
type |
Name of the dataset or data file to download when using the "year
dataset" api or |
details |
Type of detailed crash data to return (either "events" or
"vehicles"). If |
geometry |
If |
crs |
Coordinate reference system to return for |
cases |
One or more FARS case numbers. Required if |
vehicles |
numeric vector with the minimum and maximum number of
vehicles, e.g. c(1, 2) for minimum of 1 vehicle and maximum of 2. Required
for |
format |
Default "json". "csv" is supported when using the "year dataset" api. "sas" is supporting for the "zip" api. |
pr |
logical. If |
path |
File path used if download is |
download |
logical. If |
start_year |
Start year for crash reports. |
end_year |
End year for crash reports. |
head(get_fars_crashes(state = "MD", county = "Baltimore city"), 5)
get_fars_cases(state = "MD", cases = "240274")
get_fars_crash_list(state = "MD", vehicles = 5)
get_fars_summary(state = "MD")
head(get_fars_year(state = "MD", type = "PERSON"), 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.