Created
August 20, 2014 15:45
-
-
Save barryrowlingson/16fc8df160663e83bbb3 to your computer and use it in GitHub Desktop.
Work with .RData files
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
# load an object 'name' from a .RData file 'file'. | |
# eg | |
# x1 = loadFrom("foo.RData","x") | |
# x2 = loadFrom("bar.RData","x") | |
# | |
# useful when you want to load from two or more files with objects with the same name and | |
# load(file) would stomp on the second one. | |
loadFrom=function(file, name){e=new.env();load(file,env=e);e[[name]]} | |
# but what's in that .RData file anyway? Duncan Murdoch wrote this: | |
lsFrom <- function(file, all.names = FALSE, pattern) { | |
e <- new.env() | |
load(file, envir = e) | |
ls(e, all.names = all.names, pattern = pattern) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment