make_filename: Generate the filename

Description Usage Arguments Details Value Note Examples

Description

This function generates the filename for a FARS (Fatality Analysis Reporting System) datafile for the year passed as the calling parameter. It is an internal (supporting) function used by other functions in this package.

Usage

1

Arguments

year

An integer, or a value coercible to an integer. If not coercible, then an invalid filename will be generated containing "NA" as the year in the file name – accident_NA.csv.bz2 – which doesn't exist in the FARS database.

Details

This function uses the year, input parameter, to generate the file name for the FARS data file. It converts the year into an integer and then uses the sprintf() function to format the filename by prefixing "accident_" to the year and siffixing ".csv.bz2".

Value

This function returns a character string representing the filename.

Note

No other input validation is performed. It requires no other packages to be imported.

Examples

1
2
3
4
5
6
7
8
## Not run: 
make_filename(2016) # generates "accident_2016.csv.bz2"
make_filename("2016") # generates "accident_2016.csv.bz2"
make_filename(2016.5) # generates "accident_2016.csv.bz2"
make_filename("2016.5") # generates "accident_2016.csv.bz2"
make_filename("DEC-2016") # generates "accident_NA.csv.bz2"

## End(Not run)

masabri01/BuildingRPackagesCoursera documentation built on May 21, 2019, 12:39 p.m.