Pin down a file on disk from four parameters.

locate_one_file(
  filename = NULL,
  data_dir = get_data_directory(),
  year = NULL,
  type = NULL
)

Arguments

filename

Character string of the filename of the .csv to read, if this is given, type and years determine whether there is a target to read, otherwise disk scan would be needed.

data_dir

Where sets of downloaded data would be found.

year

Single year for which file is to be found.

type

One of: 'Accidents', 'Casualties', 'Vehicles'; ignores case.

Value

One of: path for one file, a message More than one file found or error if none found.

Examples

# \donttest{ locate_one_file()
#> This will download 240 MB+ (1.8 GB unzipped).
#> Coordinates and other variables may be unreliable in these datasets.
#> See https://github.com/ropensci/stats19/issues/101 and https://github.com/ropensci/stats19/issues/102
#> [1] "More than one csv file found."
locate_one_file(filename = "Cas.csv")
#> This will download 240 MB+ (1.8 GB unzipped).
#> Coordinates and other variables may be unreliable in these datasets.
#> See https://github.com/ropensci/stats19/issues/101 and https://github.com/ropensci/stats19/issues/102
#> [1] "/tmp/RtmpQtofKW/dftRoadSafetyData_Casualties_2017/Cas.csv"
# }