library(farsCoursera) library(maps) file_list <- list.files(system.file("extdata", package = "farsCoursera")) from <- lapply(file_list, function(f) { file.path(system.file("extdata", package = "farsCoursera"), f) }) to <- getwd() lapply(from, function(f) { file.copy(f, to) })
This package is designed to read data from the Fatality Analysis Reporting System, summarize the data, and map the locations of accidents.
You can install this package directly from GitHub.
install.packages("devtools") devtools::install_github("JayLKim/farsCoursera")
Once you have downloaded data files in a current working directory, fars_read_years()
imports the data. To show you
how it works, let's assume that we already have downloaded data file of 2013,
2014, and 2015. You just need to input a vector of years; then, this function
internally generates appropriate file names. So you don't need to be concerned
about a file name.
fars_read_years(c(2013, 2014, 2015))
The imported data represent all accident cases per month for a given year.
fars_summarize_years()
helps you summarize the data you imported.
fars_summarize_years(c(2013, 2014, 2015))
As you can see, it returns a tibble
representing the number of cases per
month for a given year.
fars_map_state()
draws a map in which every case is represented as a dot.
Let's assume that we want to plot every case occurred at Florida in 2013.
(See this link
for a state.num
)
fars_map_state(state.num = 12, year = 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.