Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

file.info returning NA values in r

Tags:

r

I am trying to get size of files and other details from my directory however it is returning NA values for some files but it is returning details for other files. Below is the code i used. will there be any administrator settings for files to fetch these details??

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)
like image 682
rsayam91 Avatar asked Sep 26 '17 15:09

rsayam91


1 Answers

try this: the trick is in the 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)
like image 199
Floris Padt Avatar answered Sep 18 '22 12:09

Floris Padt