The farsManipulate package provides 2 useful functions to specifically read and manipulate with the "Fatality Analysis Reporting System"(FARS) datasets. The FARS datasets provdie various information about the fatalities across the United States. For more information please visit here.
The 2 functions that this package provides primarily concerns 2 aspects of the data: the monthly fatalities of each year, and the distribution of death within a state each year. Below is a demonstration of the use of the functions within this package.

Obtaining the Monthly Fatalities of Each Year

The fars_summarize_years() function takes in vector of year(s) that user desire to extract information about that returns a tibble with each month's fatalities. One can utilize this function like this:

fars_summarize_years(2013)

which will yield 2013's monthly fatalities. In addition, the user can also use this function to inspect monthly fatalities of multiple years by typing:

fars_summarize_years(c(2013:2015))

and get the results of monthly fatalities for 2013, 2014, and 2015.

Mapping the Fatality Distribution of a State

If the user wishes to visualize the distribution of fatalities of a state within a specific year, fars_map_state() provides a map of such information. The fars_map_state() function takes two arguments: the first argument takes a number of the state (find out here at section C1 about the numerical value assigned to each state) and the second argument takes the year that the user designates.

Here is an example if the user wishes to obtain the distribution of fatalities of California in 2014:

fars_map_state(06,2014)

Upon executing this function, a map of California will appear in the plot window with dots representing each fatality.

Other functions

There are other functions that are not exported to the user because they are better implemented in the two functions introduced above, these functions are: fars_read(),fars_read_years(), and make_filename().

If the user wishes to utilize these functions, they may implement them with farsManipulate:::function_name. To learn more about how the functions operate, please utilize '?' to check their documentations.



mykoCheng/farsManipulate documentation built on May 5, 2019, 9:20 a.m.