knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(accident)
This package is made by John Hopkin university in order to evaluate the ability of students on the online R programming specialisation. This package allows to manage accidents data recorded in USA between 2013 and 2015 through the use of functions such as: fars_read fars_read_years make_filename fars_summarize_years * fars_mao_state
Read csv file if it exist in table format and creates a data frame from it. In order to realize that operation the fars_read needs a parameter filename. In fact function return data frame object if the filename exists and rises an error otherwise.
install.packages( c("readr", "dplyr") )
library("readr") library("dplyr")
fars_read(filename = "my_data.csv")
make_filename allows to Create character string which fits the filename of data base in the present package. This function uses only one parameter denoted year which is an integer value, stands for the corresponding year and allows to load the accident data from this year. * simple example
make_filename(year = 2013)
The function fars_read_years takes list of years as paramater and returns a data frame for each year that contains 2 columns denoted by the year and the Month during them at least an accident is recorded. * simple example
library("dplyr") library("magrittr") library("rlang") fars_read_years(years = c(2013, 2014, 2015))
Function fars_summarize_years Creates Cross table to Compare the couple of year and month according to the number of accidents. Roughly speaking, this function proposes a contingence table whose row is year and column represents the months in which the number of accidents are described. To perform that, fars_summarize_years uses a list or vector of years as parameter. * Simple example
library("tidyr") fars_summarize_years(years = c(2013, 2014, 2015))
fars_map_state function draws USA Map and add information on the number of accidents by depicting their location on the map. The function uses two parameters whose values stand for the state number and the year denoted by state.num and year. * Simple example
library(maps) fars_map_state(state.num = 2, year = 2013)
The package contains a set of data on the accident through the US country. Each data represents the information accident for a year amongs 2013, 2014, 2015. The datasets are denoted accident_2013 accident_2014 * accident_2015
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.