knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(fars)
This package allows you to make a map of every state and to put pointers on it based on geographical positions of accidents occurred in a given year. It takes data sets from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System and after reading them into R, it calculates the number of accidents per month for every year and then generates a map of the given state based on state.num and year arguments.
You can calculate the number of accidents in every month per year by running
fars_summarize_years
:
library(dplyr) setwd(system.file("extdata", package = "fars")) fars_summarize_years(c(2013, 2014, 2015))
In order to make a map of every state with pointers indicating geographical positions of accidents across the state you can run the following function:
setwd(system.file("extdata", package = "fars")) fars_map_state(48, 2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.