-
-
Save bmschmidt/a73b1c555897841f4b8e to your computer and use it in GitHub Desktop.
Does a lazy load across all files when provided a knitr cache directory.
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
#' 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)) | |
} | |
laziestLoad <- function(path=".") { | |
files <- list.files(path,recursive=TRUE) | |
cache_files <- sub(".rdb$", "", files[grepl(".rdb$", files)]) | |
for (i in cache_files) try(lazyLoad(i, envir = .GlobalEnv)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment