`return_latest` checks for a pattern in a folder and provides the most recent file bases on the time the file was modified

return_latest(folderpath, pattern, quiet = FALSE, ...)

Arguments

folderpath

path to folder where file(s) are located.

pattern

pattern in file name, regex expressions. If not parttern is provided, the last file in the folder will be returned.

quiet

suppresses the output message related to the file name creation, for use in sub functions, default = FALSE

...

Any other valid option for `base::list.files()`.

Value

a vector of the full filepath for the most recent version of a file stub

Examples

if (FALSE) { # \dontrun{
file_stub <- "MER_Structured_Datasets_OU_IM_FY18-20"
filepath <- return_latest("Data", file_stub)
df <- read_rds(filepath) } # }