Compute the size of directory in R
I finally used this:
system('du -s')
system('powershell -noprofile -command "ls -r|measure -s Length"')
References:
- https://technet.microsoft.com/en-us/library/ff730945.aspx
- Get Folder Size from Windows Command Line
- https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.html
- https://superuser.com/questions/217773/how-can-i-check-the-actual-size-used-in-an-ntfs-directory-with-many-hardlinks
You can also leverage cygwin if you have it; this lets you use Linux commands and get comparable results. Further there's a nice solution using Sysinternals in the last link I gave above.
"file.size" return the actual size, size on disk is the actual amount of space being taken up on the disk. check this to understand the difference . https://superuser.com/questions/66825/what-is-the-difference-between-size-and-size-on-disk try this for size of all files:
files<-list.files(path_of_directory,full.names = T)
vect_size <- sapply(files, file.size)
size_files <- sum(vect_size)