get_md_crash_data: Get and format Maryland crash data

View source: R/get_md_crash_data.R

get_md_crash_dataR Documentation

Get and format Maryland crash data

Description

Get crash data using get_md_open_data(). format_md_crash_data works with a data frame of crash data from get_md_crash_data() when type = "crashes". format_md_crashes_person() formats data when type = "persons". format_md_crashes() calls one or the other depending on the type parameter.

Usage

get_md_crash_data(
  location = NULL,
  ...,
  report_no = NULL,
  where = NULL,
  type = "crashes"
)

format_md_crash_data(data, type = "crashes", drop_code = TRUE, ...)

format_md_crashes(data)

format_md_crash_date(data, cols = c("acc_date", "acc_time"))

format_md_crashes_person(
  data,
  start_year = 2022,
  end_year = 2022,
  na_dates = c("1/1/1900", "19000101", "19001111", "19001212", "19200202")
)

Arguments

location

A sf or sfc object covering the location to return crash data.

...

Passed to get_md_open_data() for get_md_crash_data() or passed to specified formatting functions when used with format_md_crash_data().

report_no

Crash report numbers. Defaults to NULL. Optionally used to filter results if type is "persons" or "vehicles".

where

A query parameter passed to get_md_open_data()

type

Supported options include "crashes" (default), "persons" (or "crashes_person"), and "vehicles" (or "crashes_vehicle").

data

Data frame with Maryland vehicular crash data; typically from get_md_crash_data

drop_code

If TRUE (default), drop all columns that end with "code"

cols

Column names to use with format_md_crash_date().

start_year, end_year

Start and end year to use when checking validity of birth dates.

na_dates

Character vector of invalid dates to replace with a NA_character_ value.

Examples

## Not run: 
if (interactive()) {
  get_md_crash_data(
    where = "(year = '2020') AND (quarter = 'Q2')",
    name_col = "county_desc",
    name = "Cecil"
  )
}

## End(Not run)

elipousson/mapmaryland documentation built on Nov. 3, 2024, 5:11 a.m.