return_latest: Return Latest File

View source: R/return_latest.R

return_latestR Documentation

Return Latest File

Description

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

Usage

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

## Not run: 
file_stub <- "MER_Structured_Datasets_OU_IM_FY18-20"
filepath <- return_latest("Data", file_stub)
df <- read_rds(filepath) 
## End(Not run)

USAID-OHA-SI/glamr documentation built on July 6, 2024, 6:39 a.m.