#'Summarize year
#'
#' Return the number of observations per month for a given year.
#'
#' @param years an integer value, describing the year of the data set which is needed. The valid years which can be used are:\code{ 2013, 2014 & 2015}.
#'
#' @details This function using the packages: \bold{readr}, \bold{dplyr} & \bold{tidyr}.
#'
#' If an invalid year will be supplied to the function then show an Error.
#'
#' @return A tbl_df containing a representation of the data in the file.
#'
#' @importFrom dplyr bind_rows group_by summarize
#' @importFrom tidyr spread
#' @importFrom magrittr %>%
#'
#' @inheritParams fars_read_years
#'
#' @examples
#' \dontrun{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.