If you have multiple files with, say, the same prefix but a different suffix each day (for example, "myfile_20200430.csv", "myfile_20200501.csv", etc.) you can identify and load the the most recent file in the sequence as follows:
# Function to identify the most recent file with a given name pattern
# in a given folder
# mtime is the date when the file was last modified. You could change this
# to ctime to identify the latest file by the most recent creation date.
latest_file = function(fpattern, fpath) {
f = list.files(pattern=fpattern, path=fpath, full.names=TRUE)
f = file.info(f)
rownames(f)[which.max(f$mtime)]
}
myfile = latest_file(fpattern="myfile.*csv", fpath="~/downloads")
d = readr::read_csv(myfile)