Skip to content

Instantly share code, notes, and snippets.

View vkryukov's full-sized avatar

Victor vkryukov

  • Mountain View, CA
View GitHub Profile
library(digest)
LoadRDataIfExists <- function(fn) {
# Calls _fn_ and caches the result on disk, unless the cache already exists
#
# _fn_ should be a function with signature _fn(filename, ...)_
# If cache file exists and is recent, load data from it.
# Otherwise call the original function.
function (filename, ...) {
param.hash = digest(c(fn, list(...))) # Cache file names depends on params/fn def