#' Produces the number of accidents for each month for given years. Returns an error if the file does not exist. Remeber to set an appropriate working directory.
#'
#' @param years A numeric vector of years
#'
#' @return Returns the number of accidents by month for each year in a column in a data frame
#'
#' @importFrom dplyr bind_rows
#' @importFrom dplyr group_by
#' @importFrom dplyr n
#' @importFrom dplyr summarize
#' @importFrom magrittr "%>%"
#' @importFrom tidyr spread
#'
#' @examples fars_summarize_years(2013)
#'
#' @export
fars_summarize_years <- function(years) {
dat_list <- fars_read_years(years)
dplyr::bind_rows(dat_list) %>%
dplyr::group_by(year, MONTH) %>%
dplyr::summarize(n = n()) %>%
tidyr::spread(year, n)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.