Last active
January 18, 2019 20:14
-
-
Save ashiklom/afe683b17876f931c51e446f3cdd1be2 to your computer and use it in GitHub Desktop.
Read RData files into an object, rather than the global environment
This file contains 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
#' 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