R/make_filename.R

Defines functions make_filename

Documented in make_filename

#' make_filename
#'
#' This function creates a fars filename for a user specified year.
#' This file name can be passed to the fars_read function.
#'
#' @param year in 4 digit number format,'YYYY' format.
#'
#' @return A character or number vector containing a formatted combination of text and variable values.
#'
#' @section Warning: The format string is passed down the OS's sprintf function,
#' and incorrect formats can cause the latter to crash the R process .
#' R does perform sanity checks on the format, but not all possible user errors
#' on all platforms have been tested, and some might be terminal.
#'
#' @examples filename <- make_filename(2013)
#' #  filename 
#' # "accident_2013.csv.bz2"
#' 
#'
#'@export
make_filename <- function(year) {
        year <- as.integer(year)
        sprint <- sprintf("accident_%d.csv.bz2", year)
        system.file("extdata", sprint, package="fars")
}
JustinMShea/Fatality-Analysis-Reporting-System documentation built on Sept. 20, 2017, 12:01 a.m.