knitr::opts_chunk$set( collapse = TRUE, echo = FALSE, message = FALSE, eval=F, #Run the R code? messages=F, # Print out messages? warnings=F, #Print out warnings? include=F, #If FALSE, run code, but don’t print code or results warning = FALSE, comment = "#>" )
library(farsUSA)
Package farsUSA
was the practical exercise of the course Building R-packages included in the +Coursera+ Mastering Software Development in R
This package reads fars data and is able to summarize and represents accidents data for each year and USA state.
This package has internal functions devoted to read and prepare data from source, and two practical functions for summarizing and ploting data.
read a csv text file
This function reads a csv format file and stores in dataframe tbl_df. For this task uses package "readr" which allows to directly read comressed files
@param filename A character chain containing the name of the file you want to read
@return This function returns a dataframe tbl_df
fars_read("accident_2013.csv.bz2")
Creates a file name
This function creates the apropriate name of the the file corresponding to accident data for the year 'year'
@param year An integer indicating the year for filename creation
@return This function returns a character variable containing a file name
make_filename(2013)
Reads several csv text files
This function reads several csv format files and stores month and year into a list of dataframes tbl_df, containing month and year of the accidents stored, one tbl_df for each csv file.
@param years A list containing the years to estract information
@return This function returns a list of tbl_df from all years in "years" with month and year information
fars_read_years(list(2013,2014))
Summarizes accidents by year and month
This function summarizes the number of accidents occurred each month for a list of years
@param years A list of years
@return This function returns a tbl_df containing number of accidents by month for the years included in the list parsed as parameter
fars_summarize_years(list(2014,2015))
Print a map of crash over year and state of U.S.
This function prints a map with the position of every crash occurred over the state 'state.num' and the year 'year'
@param state.num integer with the number of desired state, ranging 1:56 @param year An integert with the desired year
@return This function returns a map
fars_map_state(1, 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.