R find time when a file was created

允我心安 提交于 2019-12-21 07:08:46

问题


I am using R function list.files to get a list of files in a folder. I would also like to record when each file was created, modified and accessed

how can i do that? i tried google search, but didnt find any useful command

Below screenshot is from my Windows machine. I get it when i right click a file name and click "properties"


回答1:


Check out file.info() for this and other file properties:

## With a single path
p <- R.home()
file.info(p)$ctime
# [1] "2014-11-20 08:15:53 PST"

## With a vector of multiple paths
paths <- dir(R.home(), full.names=TRUE)
tail(file.info(paths)$ctime)
# [1] "2014-11-20 09:00:45 PST" "2014-11-20 09:00:47 PST"
# [3] "2014-11-20 09:00:47 PST" "2014-11-20 09:00:50 PST"
# [5] "2014-11-20 09:00:33 PST" "2014-11-20 09:00:33 PST"


来源:https://stackoverflow.com/questions/27066620/r-find-time-when-a-file-was-created

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!