0

I have multiple excel files in multiple directories that I am reading into R. However, I don't want to read in EVERY excel file; I only want to read in the most recent ones (for example, only the ones created in the last month). Is there a way to do this?

Currently I am using this to read in all of the excel files, which is working just fine:

filenames <- Sys.glob(file.path('(name of dir)', "19*", "Electrode*02.xlsx")) <br> 
elecsheet <- do.call("cbind", lapply(filenames, read_excel))

Somewhere in this second line of code (I think), I need to tell R to look at the metadata and only read in the excel files that have been created since a certain date. Thank you!

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
Kylie Baer
  • 31
  • 2
  • 1
    You're probably looking for the `ctime` column returned by the function `file.info`, with some standard caveats that what your OS provides as information for that field may or may not be reliable. – joran Jun 12 '19 at 20:08
  • 1
    file.info(dir()) will give you file date – M.Viking Jun 12 '19 at 20:09

0 Answers0