R创建文件时找到时间 [英] R find time when a file was created

查看:138
本文介绍了R创建文件时找到时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用R函数list.files来获取文件夹中的文件列表。我还想记录每个文件的创建,修改和访问时间



我该怎么做?我试图谷歌搜索,但没有发现任何有用的命令



下面的截图是从我的Windows机器。我得到它时,我右键单击文件名称,然后单击属性





  ##使用单个路径
p <-R .home()
file.info(p)$ ctime
#[1]2014-11-20 08:15:53 PST

##使用向量多个路径
paths< - dir(R.home(),full.names = TRUE)
tail(file.info(paths)$ ctime)
#[1]2014 -11-20 09:00:45 PST2014-11-20 09:00:47 PST
#[3]2014-11-20 09:00:47 PST2014-11- 20 09:00:50 PST
#[5]2014-11-20 09:00:33 PST2014-11-20 09:00:33 PST


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"

解决方案

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"

这篇关于R创建文件时找到时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆