Re: [R] change object name within for loop

2010-08-20 Thread David Winsemius
On Aug 20, 2010, at 1:07 PM, Gonçalo Ferraz wrote: Hi, I am writing a for loop that creates one object, say 'outn' on every round of the loop. I would like the name of each object to include the index of the loop as in, for example: out1, out2, out3, ... ?assign ?paste And I would l

Re: [R] change object name within for loop

2010-08-20 Thread Gene Leynes
The quick answer is to use a list. The most simple: outlist=list() for (i in 1:10){ outlist[[i]] = matrix(rnorm(100), 10, 10) } Same example, but with naming: outlist=list() for (i in 1:10){ outlist[[i]] = data.frame(loop_number=i, matrix(rnorm(100), 10, 10)) } now if you were to do final_

Re: [R] change object name within for loop

2010-08-20 Thread Erik Iverson
Gonçalo Ferraz wrote: Hi, I am writing a for loop that creates one object, say 'outn' on every round of the loop. I would like the name of each object to include the index of the loop as in, for example: out1, out2, out3, ... And I would like the naming of the object to take place automat

[R] change object name within for loop

2010-08-20 Thread Gonçalo Ferraz
Hi, I am writing a for loop that creates one object, say 'outn' on every round of the loop. I would like the name of each object to include the index of the loop as in, for example: out1, out2, out3, ... And I would like the naming of the object to take place automatically as the loop mo