Created
          January 14, 2016 15:28 
        
      - 
      
- 
        Save smalik/8b8bdad8b901f92a9edb to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Ripped off from http://stackoverflow.com/questions/21754319/rule-of-thumb-for-memory-size-of-datasets-in-r | |
| # original author Carlos Cinelli | |
| howMuchRAM <-function(ncol, nrow, cushion=3){ | |
| #40 bytes per col | |
| colBytes <- ncol*40 | |
| #8 bytes per cell | |
| cellBytes <- ncol*nrow*8 | |
| #object.size | |
| object.size <- colBytes + cellBytes | |
| #RAM | |
| RAM <- object.size*cushion | |
| cat("Your dataset will have up to", format(object.size*9.53674e-7, digits=1), "MB and you will probably need", format(RAM*9.31323e-10,digits=1), "GB of RAM to deal with it.") | |
| result <- list(object.size = object.size, RAM = RAM, ncol=ncol, nrow=nrow, cushion=cushion) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment