fars_summarize_years: Count FARS Traffic Accidents by Month and Year

Description Usage Arguments Details Value See Also Examples

View source: R/fars_functions.R

Description

'fars_summarize_years()' produces a summary statistic of the fatal traffic crash data compiled by the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System (FARS). The function lets you count monthly totals of fatal traffic accidents on an annual basis.

Usage

1

Arguments

years

a numeric vector of four digit numbers represents years in the format 'YYYY'

Details

See here for more information about FARS|NHTSA.

Value

a summary or pivot table of monthly total values, generated by pivoting a tibble wider, with rows by months and columns by years; An invalid value (year) specified in the input will cause a NULL value generated while reading data from corresponding file, missing value (column) for the invalid year in the output, and a warning message "invalid year: ...". Completely invalid input will cause a "Must group by variables found in '.data'" error in addition to warning messages of "invalid year: ..."

See Also

fars_read_years which this function wraps

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
fars_summarize_years(c(2013,2014,2015))

## End(Not run)
## Not run: 
yrs <- 2013:2015
monthly_counts <- fars_summarize_years(years=yrs)

## End(Not run)

johnxz/farsr documentation built on Dec. 21, 2021, 2:14 a.m.