Retrieves the path of a file stored in basepath/fname that has the closest modification date to goalDate. If no such file exists, an error will be thrown.

retrievePath(fname, basepath = ".", goalDate = lubridate::now())

Arguments

fname

The name of the directory in basepath where various revisions of the file are stored. I.e., file.txt should be a directory, with revisions of the true file.txt stored inside of it.

basepath

A string. The path which stores fname. Default '.'

goalDate

The 'goal' date for the revision we are trying to retrieve. Whichever file is closest in time to the 'goal' date will be selected

Value

A string. The full path to the file, or an error if such a file cannot be found.

Examples

storeRDS(mtcars, 'mtcars')
#> Wrote object to ./mtcars/2020_04_16_23_22.rds
retrievePath('mtcars', goalDate=lubridate::now() - lubridate::days(10))
#> [1] "./mtcars/2020_04_09_18_08.rds"