knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(trafficR)
First we need to create the filename for a given accident data.
#get filename fname <-make_filename(2013) fname file.path("..","data",fname)
Next we can read in a single data set using the file name we just created. Each row of the data represents a single accident.
df <- fars_read(fname) head(df)
If you need to read in multiple years just use fars_read_years. In the following example only 2013 and 2014.
fars_read_years(2013:2014)
Now to get the summary of the counts by year we can use the following function.
fars_summarize_years(2013:2014)
Lastly we will plot map of accidents for California using fars_map_state
fars_map_state(state.num=6, year=2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.