knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Load farse data from csv file
This function will used to import csv file to tydeverse tibble format.
Import will check if file exists. In case that file does not exist, function will stop.
fars_read(filename)
Simple function, that will create file name from imput string or
number. In case that input is not numeric, than function changes
type to numeric.
make_filename('2015')
make_filename(2015)
Function fars_read_years reads in multiple files and creates list of tibbls
Function will take in vector of years, either in string or numbers.
fars_read_years will use functions make_filename, to create file name
to by loaded into list. Function fars_read will be also used in order to
read in cvs files. Final step of the function will be adding new column year
from variable year.
fars_read_years will have check on existance of csv file with year, that was entered
in vector of years.
fars_read_years(c(2013, 2014))
fars_read_years(c('2013', '2014'))
This function will return tibble of values that have number of
combinations of months and years.
This function uses output from fars_read_years which has output of list of
tibbles. Secund step is creating union of all tibbles into one table. Third step
is creating summaries of number combinations by year and month. final step is
to create new table with values of month in columns and number of existing
combinations as values in columns.
fars_summarize_years(2015)
fars_summarize_years('2015')
Function fars_map_state reads in fars data for one state and displays number
of occurences on the map
This function will return map of selected state with number of occurences
by GPS cordinates with lattitude and longitude.
This function uses two previusly defined functions: make_filename (for creating
a name of imported file) and make_filename (for loading csv file from file).
In the secund step it verifies if the state.number is in the unique list of
states. In case that number is not correct, than execution of function is stoped.
Next step is to filter tibble by selected state. Secund check is done in order to
verify if there are any accidents in mentioned state. Final step of function is
to plot number of accindents on the map by lattitude and longitude.
fars_map_state(13, 2015)
fars_map_state(13, '2015')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.