knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The package includes 5 functions:
While it may not be neccesary, the following package will ensure the above functions run smoothly: dplyr, tidyr, readr and maps
library(dplyr) library(readr) library(tidyr) library(maps) library(fars)
Lets read in the fars for 2013 data. Of course you can also use make_filename to create the file name. All the exploratory work should starts here before proceeding to the next functions.
file <- make_filename(2013) data <- fars_read(filename = file) dim(data) head(names(data))
If Month and years of the accidents are the only things you want, then fars_read_year can be called. Moreover, the fars_summarize_years will take that result and output a summary of total accidents by months/year
data <- fars_read_years(c(2013, 2014)) data <- fars_summarize_years(c(2013, 2014)) data
Lastly, the fars_map_state function will plot the total accidents by state and year.
fars_map_state(state.num = 31, year = 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.