Skip to content
Prev 301535 / 398503 Next

Assigning a new name to object loaded with "load()"

Here is one way.  You seem to assume that the save file contains
exactly one object and this function makes the same assumption:
theObjectSavedIn <- function(saveFile) {
     env <- new.env()
     load(saveFile, envir=env)
     loadedObjects <- objects(env, all=TRUE)
     stopifnot(length(loadedObjects)==1)
     env[[loadedObjects]]
 }

Use it as
[1] 101 102 103 104 105 106 107

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com