Skip to content

Instantly share code, notes, and snippets.

@ashiklom
Last active January 18, 2019 20:14
Show Gist options
  • Save ashiklom/afe683b17876f931c51e446f3cdd1be2 to your computer and use it in GitHub Desktop.
Save ashiklom/afe683b17876f931c51e446f3cdd1be2 to your computer and use it in GitHub Desktop.
Read RData files into an object, rather than the global environment
#' Read an `Rdata` file into a list (rather than into the global
#' environment)
#'
#' @param file Target file name
#' @return Named list containing objects in `file`.
#' @author Alexey Shiklomanov
#' @examples
#' \dontrun{
#' mylist <- load_local("file.RData")
#' }
#' @export
load_local <- function(file) {
menv <- new.env(parent = baseenv())
load(file, envir = menv)
as.list(menv)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment