Description Usage Arguments Details Value Note Examples
This function can be used to get a "tidy" data frame of FARS data for multiple years. Data is summarized by each month of each year with each year in its own column.
| 1 | fars_summarize_years(years)
 | 
| years | A vector of years | 
This function processes each element of a vector or list of years
as follows:
- calls the supporting function, fars_read_years(), to
generate a list of MONTH and year,
- calls the bind_rows() function from the dplyr
package to merge the list elements (MONTH and year) into a
single dataframe,
- calls the group_by() function from the dplyr
package on the dataframe to group them by year and MONTH,
- calls the summarize() function from the dplyr
package on the grouped data to count the number of occurrences
of fatalities for each month within each year, and finally
- calls the spread() function from the tidyr
package on the summarized data to create a column for each year.
- Returns the tidy dataframe to the calling function.
This function returns a dataframe comprising of years (provided as the input parameter) as columns with the fatalities summarized by each month.
Following functions need to be imported:
dplyr package: bind_rows(), group_by(), and
summarize().
tidyr package: spread.
No error handling is performed in this function.
| 1 2 3 4 5 6 | ## Not run: 
fars_summarize_years(c(2014, 2015, 2016))
fars_summarize_years(c(2014:2016))
fars_summarize_years(list(2014, 2015, 2016))
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.