saveload

Store the results of long-running computations on disc.
The next time a script is run, they are loaded quickly.

if(  file.exists("objects.Rdata")  )
  {
  load("objects.Rdata") # load previously saved objects
  }  else
  {
  obj1 <-   mean(rnorm(2e7))             # in the first run,
  obj2 <- median(rnorm(2e7))             # compute the objects
  save(obj1, obj2, file="objects.Rdata") # and write them to disc
  }

If you need to rerun an analysis if the last run is older then 6 hours, this could be the condition:

difftime(Sys.time(), file.mtime("objects.Rdata"), units="h") > 6

For a single object, a good alternative to save and load is:

saveRDS(one_single_object, "object.Rdata")
explicit_object_name <- readRDS("object.Rdata")

More on this topic from Rcrastinate