-
Notifications
You must be signed in to change notification settings - Fork 0
/
fars.Rmd
84 lines (57 loc) · 1.67 KB
/
fars.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
title: "Fatality Analysis Reporting System (FARS)"
author: "ZIDA"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
# Package Description
`fars` package reads and plots Fatality Analysis Reporting System (FARS) data
from the [National Highway Traffic Safety
Administration](https://www.nhtsa.gov/research-data/fatality-analysis-reporting-system-fars).
[FARS](https://en.wikipedia.org/wiki/Fatality_Analysis_Reporting_System) is a
nationwide census, providing the American public yearly data, regarding fatal
injuries suffered in motor vehicle traffic crashes.
## Load Packages
```{r}
library(fars)
library(maps)
```
## Included data
Data files included within the package are:
```{r}
list.files(system.file("extdata", package = "fars"))
```
## Package Functions
### Function `make_filename`
This function returns file name and path to the data files:
```{r}
yr <- 2015
make_filename(yr)
```
### Function `fars_read_years`
Ancillary function used by `fars_summarize_years`
```{r}
fars_read_years(2013)
```
### Function `fars_summarize_years`
This function summarizes yearly accidents data, by month.
```{r}
plot(fars_summarize_years(2015))
fars_summarize_years(c(2015, 2014))
```
### Function `fars_map_state`
The function displays a state map plot including accidents location
by year
```{r}
state_num <- 49 # Utah
yr <- 2014
fars_map_state(state_num, yr)
```
# Links:
* [Package fars GitHub](https://github.com/ZYDI/FARS)
* [Package fars Travis CI](https://travis-ci.org/ZYDI/FARS)
* [Package Appveyor](https://ci.appveyor.com/project/ZYDI/FARS)