file.info返回r中的NA值

时间:2017-09-26 15:39:47

标签: r

我正在尝试从我的目录中获取文件大小和其他详细信息但是它返回了某些文件的NA值,但它返回了其他文件的详细信息。以下是我使用的代码。是否会有文件的管理员设置来获取这些详细信息?

library(tidyr)
library(dplyr)
wd <- "F:\\working\\others"
setwd(wd)
#get file list - your list of files would be different
fileList <- list.files()[1:240]
class(fileList)
#result
cbind(
  file.info(fileList)[,c("size"), drop=FALSE],
  x = as.character(file.mtime(fileList))) %>% 
  separate(x,
           into = c("DateModified","TimeModified"),
           sep=" ") %>% 
  add_rownames %>% 
  select(DateModified,
         TimeModified,
         Size=size,
         FileName=rowname)

1 个答案:

答案 0 :(得分:2)

尝试: 诀窍在于full.names = TRUE

ldir <-  normalizePath("<type here the path of directory>")
finf <- file.info(dir(path = ldir, full.names = TRUE), extra_cols = FALSE)
View(finf)