This will return the latest created file matching
the criteria. It uses fs::dir_info() to
find the files then picks the one with the latest
birthtime.
Arguments
- directory
The directory in which to search.
- regexp
a regular expression passed to
fs::dir_info()to search for the file.- selection_method
Valid arguments are "modification_date" (the default) or "file_name".
Value
the fs::path() to the file
Examples
if (FALSE) { # \dontrun{
find_latest_file(
directory = get_lookups_dir(),
regexp = "Scottish_Postcode_Directory_.+?\\.rds"
)
} # }