make_filename: Generate the name of the file

Description Usage Arguments Details Value Note Examples

Description

make_filename is a function that generates the file name of the csv file to be read.

Usage

1

Arguments

year

An integer or string indicating the year that generate the data file.

Details

This function uses the year (input) to generate the file name for the Fatality Analysis Reporting System (FARS) data file. It converts the year into an integer and then uses the sprintf() function to format the file name.

Value

The name of the file as a string.

Note

The year parameter of this function must be an integer or a string with number. If year parameter is invalid, then an invalid file name will be generated containing "NA" as the year in the file name which doesn't exist in the FARS database.

Examples

1
2
3
4
5
6
## Not run: 
make_filename(2014) #generates "accident_2014.csv.bz2"
make_filename("2015") #generates "accident_2015.csv.bz2"
make_filename("abcd") #generates "accident_NA.csv.bz2"

## End(Not run)

lahstorti/FARS.functions documentation built on May 15, 2019, 3:32 p.m.