This package consists of a set of functions that explore a files containing counts of accidents information monthly, and yearly.
To install this package copy and paste the following line into your R console.
library(devtools)
devtools::install_github("elssam/RPackage")
Alternatively, you can clone the github repo (manually or from the command line) and then run the following into your R console
devtools::load_all()
library(tidyr)
library(readr)
library(maps)
library(graphics)
library(magrittr)
library(dplyr)
Load all if you clone the package with devtools::load_all()
or install the package from
devtools (see Readme file for more details.)
You will need to load knitr with library(knitr)
.
The following This function takes a file name as an argument and checks if it exists before reading it as an R dataframe
fars_read("accident_2013.csv")
The following function takes a file name as an argument and checks if it exists before reading it as an R dataframe
fars_read("accident_2013.csv")
The following function takes as an argument the year for which the user wishes to acquire data and accordingly creates the associated file name
make_filename(2013)
This function takes a vector of years as an argument and provides a list, each element of the list is a data frame (corresponding to one element in the vector) with two columns, the \code{year} and \code{MONTH} that correspond to each accident
fars_read_years(c(2013,2014))
The following function takes a vector of specific years as an argument and returns a summary of the count (e.g. fatal injuries in motor vehicle traffic crashes) per month within the years provided
fars_summarize_years(c(2013,2014))
This function plots a map of accidents' locations which occurred within a specified year in a given state.
fars_map_state('34',2013)