rdownloadunzipfilesize

How to check file size before opening?


How can I check the size of a file before I load it into R?

For example:

http://math.ucdenver.edu/RTutorial/titanic.txt

I'd like to use the optimal command to open a file based on the file's size.


Solution

  • Use file.info()

    file.info("data/ullyses.txt")
    
                        size isdir mode               mtime               ctime               atime  uid  gid
    data/ullyses.txt 1573151 FALSE  664 2015-06-01 15:25:55 2015-06-01 15:25:55 2015-06-01 15:25:55 1008 1008
    

    Then extract the column called size:

    file.info("data/ullyses.txt")$size
    [1] 1573151