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

datfolder <- system.file("extdata", package = "courseraFARS")
file.copy(
  file.path(datfolder, dir(datfolder)),
  file.path(getwd(), dir(datfolder))
)

Read, summarise and visualize Fatality Analysis Reporting System data

This package comes with a limited number of very basic functions. To demonstrate the use of these, the package comes with raw csv files which can be accessed with the following command:

datfolder <- system.file("extdata", package = "courseraFARS")
dir(datfolder)
library(courseraFARS)
  1. fars_read loads the csv data into a tibble::tbl_df
(x <- fars_read(dir(datfolder)[1]))
  1. fars_read_years loads multiple csv files into a list of tibbles with only the MONTH and year columns.
(x <- fars_read_years(2013:2015))
  1. fars_summaize_years returns tibble with counts for each month in the specified years
(x <- fars_summarize_years(2013:2015))
  1. fars_map_state can be used for plotting the geographical coordinates of fatal injuries within a year for the specified state.
fars_map_state(1, 2013)
file.remove(dir(datfolder))
rm(datfolder)


SinanPolatoglu/coursera_pkgdev documentation built on Jan. 26, 2020, 12:55 a.m.