cvmartin
9/28/2017 - 8:23 AM

Load RDS from Amazon S3 into disk and memory

Amazon S3 is perfect to store relatively large files like random forest models, that then can be loaded into VPS to perform operations. The trick is to take the object only if it is not already in the disk (because you can expect it to be big). If it is already, then load it directly into memory

load_rds_s3 <- function(object, bucket = "enerflows") {
  if (!file.exists(object)) {
    save_object(object,
                file = object,
                bucket = bucket)
  }
  readRDS(object)
}