Skip to content

Instantly share code, notes, and snippets.

@zkamvar
Last active September 11, 2015 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zkamvar/655be26d1d5bec1ac948 to your computer and use it in GitHub Desktop.
Save zkamvar/655be26d1d5bec1ac948 to your computer and use it in GitHub Desktop.
Does a lazy load across all files when provided a knitr cache directory.
#' Performs lazy load on a directory
#'
#' @param path a filepath containing the necessary files for lazy loading
#' @return NULL
#'
#' @details This function will go into a directory, search for all the files
#' that seem like they can be lazily loaded and attempt to load them.
#'
lazierLoad <- function(path){
files <- dir(path)
cache_files <- sub(".rdb$", "", files[grepl(".rdb$", files)])
for (i in cache_files) try(lazyLoad(paste(path, i, sep = "/"), envir = .GlobalEnv))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment