Skip to content

Instantly share code, notes, and snippets.

@barryrowlingson
Created August 20, 2014 15:45
Show Gist options
  • Save barryrowlingson/16fc8df160663e83bbb3 to your computer and use it in GitHub Desktop.
Save barryrowlingson/16fc8df160663e83bbb3 to your computer and use it in GitHub Desktop.
Work with .RData files
# 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