Skip to content
Prev 324561 / 398506 Next

Loading an .RData file and assigning the loaded objects within a loop

On Sat, Jun 1, 2013 at 6:18 AM, Jeremy Ng <jeremy.ng.wk1990 at gmail.com> wrote:
If Files is a character vector containing the filenames then this
creates a list witih one componet per RData file. The list names will
be the file names.  Each component is itself a list containing the
objects in that file:

    L <- sapply(Files, function(x) mget(load(x)), simplify = FALSE)

(If it is known that each RData file contains only a single object
then mget could be replaced with get in which case each component of L
would be the object in the respective file.  In that case you will
lose the object names but as you indicated they are all the same that
likely won' t matter.)

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com