knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
FARS is a nationwide census providing NHTSA, Congress and the American public yearly data regarding fatal injuries suffered in motor vehicle traffic crashes. The data files are in CSV format, often compressed. Function could read CSV and BZ2 files as well. It has 50 variables=columns (eg. STATE, CITY, COUNTY, DAY, MONTH, YEAR, FATALS etc.), and around 30k records.
html_vignette for FARS package shows basic usage of the functions provided.
This package contains the following R functions for analysing FARS data:
Below we could see the location of the FARS data file attached to this package.
library("MyFirstPackage") library(dplyr) fars2013_path <- system.file("extdata","accident_2013.csv.bz2", package = "MyFirstPackage") fars2014_path <- system.file("extdata","accident_2014.csv.bz2", package = "MyFirstPackage") fars2015_path <- system.file("extdata","accident_2015.csv.bz2", package = "MyFirstPackage") fars2013_path fars2014_path fars2015_path
fars_summarize_years() shows summary for given years for each month in table.
apath <- dirname(fars2015_path) setwd(apath) fars_summarize_years(c(2013, 2014, 2015))
Summary of fatalities for each month of 2013 year.
fars_map_state shows accidents locations on the map:
apath <- dirname(fars2015_path) setwd(apath) fars_map_state(1,2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.