knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Dear reader! Have you ever downloaded the US Fatality Analysis Reporting System data and thought 'Oh, I might need to write an R package based on it'?

Me neither, but let's do that anyway :)

fars_read()

The functions can do many things. If you ever got tired from reading endless warning and other messages in red in the console, you can always use the first function fars_read()

And because we are dealing with the FARS data -- for the sake of the exaple, we added a sample csv file to a package directory. So don't you worry about it

library(exmplr)
my_df = fars_read("accident_2013.csv.bz2")

head(my_df,10)

In case you you need the raw file, you can access it using the following path: system.file("extdata", "accident_2013.csv.bz2", package = "exmplr")

make_filename()

The names of the FARS data files are complex, especially of the .bz2 compression. Let's try to deal with that. You can simply provide the year that you need to access and then use the result as an input to the fars_read() function.

make_filename(2013)

fars_summarize_years()

You can also try and summarise the number of observations per month for a given year. You can do that by providing a year to the fars_summarize_years() function

fars_summarize_years(2013)

fars_map_state()

We can also build a beautiful bw maps with the distribution of accidents accross any of US state.

fars_map_state(1, 2013)


Liddlle/exmplr documentation built on May 18, 2019, 1:34 p.m.