1

I was wondering if there's some function that given a file name + path can asses how much RAM R will need to use it? i want to be able to know this info before I'm loading it.

Yehoshaphat Schellekens
  • 2,305
  • 2
  • 22
  • 49
  • I don't think there is such a function. You can still take a guess depending on how well you know your data and R's read capabilities. This only for 'reading it in'. – asb Jun 19 '14 at 05:08
  • This could work if your doing some analysis with well known data, but in case you want to create a robust software that would potentially use many kinds of data sets (what im looking for) , that won't help – Yehoshaphat Schellekens Jun 19 '14 at 05:11
  • 1
    You really need to know a lot about the data. Numbers generally take fewer bytes to store in memory than they do in plain text. But then things like factors are stored efficiently so each repeated string is only stored once so the storage is basically just an integer. So i'm thinking file size is an upper limit, but the reduction can vary greatly depending on the entire file contents. – MrFlick Jun 19 '14 at 06:06

1 Answers1

1

You can use 'fstat' http://linux.die.net/man/2/fstat

It will report information about your file, such as actual filesize.

struct stat {
    dev_t     st_dev;     /* ID of device containing file */
    ino_t     st_ino;     /* inode number */
    mode_t    st_mode;    /* protection */
    nlink_t   st_nlink;   /* number of hard links */
    uid_t     st_uid;     /* user ID of owner */
    gid_t     st_gid;     /* group ID of owner */
    dev_t     st_rdev;    /* device ID (if special file) */
    off_t     st_size;    /* total size, in bytes */
    blksize_t st_blksize; /* blocksize for file system I/O */
    blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
    time_t    st_atime;   /* time of last access */
    time_t    st_mtime;   /* time of last modification */
    time_t    st_ctime;   /* time of last status change */
};
user3747345
  • 398
  • 1
  • 6