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

2013-06-01 Thread Jeremy Ng
Hi all, I tried to look this up online, but am still feeling a little stuck. I have a bunch of Rdata files in side my directory, and I would like to load all of them in a loop. Each time the next is read in, it would over-write the previously read in object because they will be assigned the same

Re: [R] Loading an .RData file and assigning the loaded objects within a loop

2013-06-01 Thread Jim Holtman
use 'lapply' to read in the .RData file. Therefore each file is stored as an element of a list thatb you can access and change as necessary. Sent from my iPad On Jun 1, 2013, at 6:18, Jeremy Ng jeremy.ng.wk1...@gmail.com wrote: Hi all, I tried to look this up online, but am still feeling

Re: [R] Loading an .RData file and assigning the loaded objects within a loop

2013-06-01 Thread Barry Rowlingson
Within lapply load the file and return the value of the thing or things in the file you want. Something like this: files [1] x1.RData x2.RData x3.RData x4.RData lapply(files,function(z){load(z);x}) [[1]] [1] 1 [[2]] [1] 22 [[3]] [1] 333 [[4]] [1] Each of my files contains a single

Re: [R] Loading an .RData file and assigning the loaded objects within a loop

2013-06-01 Thread Gabor Grothendieck
On Sat, Jun 1, 2013 at 6:18 AM, Jeremy Ng jeremy.ng.wk1...@gmail.com wrote: Hi all, I tried to look this up online, but am still feeling a little stuck. I have a bunch of Rdata files in side my directory, and I would like to load all of them in a loop. Each time the next is read in, it would