Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compute the size of directory in R

Tags:

directory

r

size

I want to compute the size of a directory in R. I tried to use the list.info function, by unfortunably that follows the symbolic links so my results are biased:

# return wrong size, with duplicate counts for symlinks
sum(file.info(list.files(path = '/my/directory/', recursive = T, full.names = T))$size)

How do I compute the file size of a directory, so that it gives me the same result as on Linux, e.g. with du -s for example?

Thanks

like image 201
Carmellose Avatar asked Sep 28 '16 16:09

Carmellose


1 Answers

I finally used this:

system('du -s')
like image 176
Carmellose Avatar answered Sep 22 '22 13:09

Carmellose