A more detailed directory listing in R?

r

Solution

Look up the ctime (or other) and return the appropriate file:

x <- dir()
y <- file.info(x)
row.names(y[y$ctime==max(y$ctime),])

Problem

A function I wrote generates an output file. Additional functions can take the content of that file (the name has a pattern that can be easily matched), and do more. Currently one could do the following: ``` function1(...) # This will generate a file, say output_typea.md # Then one could process this content further using function2(input_file = 'output_typea.md') ``` However, since these two functions are meant to be run in sequence, I'd like to just let users call `function2()` and missing input would just read the most recent file matching the `dir(pattern = "*_type.md")`. Unfortunately it doesn't seem possible to sort `dir()` listings by date modified. All I need is the most recent file matching file name pattern. Any ideas?

Original source