#' Select data
#' This function harvests data from the file for summary or drawing maps.
#' Users don't need to do this separately, thus this function is not exported.
#'
#' @param years The year of the accidents recorded
#' @inheritParams make_filename
#' @return This function returns month data of the accidents in the accident file
#' @importFrom dplyr mutate select
fars_read_years <- function(years) {
lapply(years, function(year) {
file <- make_filename(year)
tryCatch({
dat <- fars_read(file)
dplyr::mutate_(~ dat, year = ~ year) %>%
dplyr::select_(~ MONTH, ~ year)
}, error = function(e) {
warning("invalid year: ", year)
return(NULL)
})
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.