Skip to content
Prev 325542 / 398503 Next

load() into a data frame with my chosen name => .ThisEnv ?

Did you try using load's 'envir' argument, which should be mentioned in its help file?
E.g., define the function
   getMyData <- function(RDataFile) {
       # RDataFile should be *.RData file containing exactly one object
       .ThisEnv <- new.env(parent = emptyenv())
       loadedNames <- load(file=RDataFile, envir=.ThisEnv)
       stopifnot(length(loadedNames)==1)
       .ThisEnv[[ loadedNames ]]
   }
and use it in the loop as
  d <- getMyData(RDataFile = fname)
   

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com