R中更详细的目录列表?

Mai*_*ura 4 r

我写的函数生成一个输出文件.附加功能可以获取该文件的内容(名称具有可以轻松匹配的模式),并执行更多操作.目前可以做以下事情:

function1(...)
# This will generate a file, say output_typea.md
# Then one could process this content further using
function2(input_file = 'output_typea.md')
Run Code Online (Sandbox Code Playgroud)

但是,由于这两个函数是按顺序运行的,我想让用户调用function2(),缺少输入只会读取与之匹配的最新文件dir(pattern = "*_type.md").不幸的是,似乎无法dir()按修改日期对列表进行排序.我需要的是最新的文件匹配文件名模式.有任何想法吗?

Mat*_*erg 7

查找ctime(或其他)并返回相应的文件:

x <- dir()
y <- file.info(x)
row.names(y[y$ctime==max(y$ctime),])
Run Code Online (Sandbox Code Playgroud)