title: "README" author: "FG" date: "3/11/2017" output: html_document
This package include 5 functions:
Read .csv data file
This function check for the existance of a given filename
, and if the .csv file exist,
it read it and convert it into dataframe.
If the filename
you provide does not existe, the function stops and return an error message
read_csv
is evaluated in a context that ignores all ‘simple’ diagnostic messages.
Parameters:
filename
A character string giving the name or path of the csv file to be read. Accepts compressed csv file.This function returns a dataframe with data read from a .csv file.
Dependencies:
readr::read_csv
dplyr::tbl_df
Examples:
fars_read("filename.csv")
fars_read("pathname/filename.csv")
Print filename for a given year.
This function print a character vector with the filename combining the default file name and the year
passed as argument to the function
Parameters:
year
An integer. The function coherce the passed value to an integerThis function returns a character vector containing a formatted combination of text and year number.
Examples:
make_filename(2017)
make_filename(4034/2)
Read multiple .csv data file for a series a provided years
This function take as input a vector of integers (years
) representig years, make the
defalut filename for each year, and read the data in and convert it into data frame.
For each year with no data file, the function returns an error message.
Parameters:
years
A vector of integers representing a series of yearsThis function returns a dataframe with 2 columns for each year, representing month number and year of each recorded data.
Dependencies:
dplyr::mutate
dplyr::select
Examples:
fars_read_years(2013)
fars_read_years(2013:2015)
Summarize records per month for a series a provided years
This function takes a series of years (years
) as input and returns a tibble with
the number of records per month, by year.
Parameters:
years
A vector of integers representing a series of yearsDependencies:
dplyr
tidy::spread
Examples:
fars_summarize_years(2013)
fars_summarize_years(2013:2015)
Plot a map with all accidents in a given State in a given year.
This function takes a State number (state.num
) indicator and a year (syear
), and plots a map with all the accident recorded in the given State/year.
If the State number does not exhist in the data for the given year returns a message with "invalid STATE number". If there are no accidents in the given State for the given year, it returns a messagesaying "no accidents to plot".
Parameters:
state.num
an integer representing a State code number. It is coherced into an integer.year
an integer representing a year.Dependencies:
dplyr::filter
maps::map
graphics::points
Examples:
fars_map_state(23, 2013)
This Vignette was created as part of the final assignment to the cours "Building R Packages" from JHU through Coursera.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.