| find_file | R Documentation | 
Find particular file within a directory and return its name/path.
find_file(
  path,
  name_pattern,
  slice_n = NULL,
  date_filter = NULL,
  date_pattern = NULL,
  date_format = NULL,
  file_time = "ctime",
  ...
)
| path | File path that contains files of interest (can look into child folders using  | 
| name_pattern | Basic regular expression to discover names within a file path. | 
| slice_n | Grab the n-th file from the list (descending order by date). Default set to  | 
| date_filter | Reduce set of discovered file based upon a date threshold (default:  | 
| date_pattern | Regular expression to search file name for date, parsed with  | 
| date_format | POSIX formatted dates or date/times (e.g.  | 
| file_time | Character vector, one of  | 
| ... | Additional parameters passed to  | 
There are two ways to discover the n-th file of interest. Based upon the file name search pattern, the date is sorted either by
creation date (ctime) or a provided pattern (date_pattern) and format (date_format) within the file name itself.
Returns character vector, file name.
## Not run: 
# Find latest file for particular excel file using basic pattern
latest_file <- find_file("/taget_folder",
                 "^target_name.*\\.xlsx",
                 recursive = TRUE)
# Find latest .rds file by the date in the file name itself
latest_file <- find_file(path = "./taget_folder",
                 name_pattern = "^target_data_(\\d{4}\\-\\d{2}\\-\\d{2})[ ]({1}\\d{2}\\-\\d{2})\\.rds$",
                 date_pattern = "(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}-\\d{2})",
                 date_format = "%Y-%m-%d %H-%M",
                 date_filter = lubridate::today()-10, # Only keep less than today and slice the top value
                 full.names=FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.