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_output=do.call('rbind', outlist) You'd have something that you can probably work with. str(final_output) Lists are kind of weird, but they're worth exploring. Remember that the output of [ is a list and [[ returns the actual item. So to get the third data.frame you'd want to use outlist[[3]] 2010/8/20 Gonçalo Ferraz <gferra...@gmail.com> > 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 moves through? > > Similarly, I would like to be able to call different objects (in1, in2, > in3, ...) authomatically through the execution of the loop. > > Is there a quick solution for this? Thank you for any help. > > I apologize if this question has been addressed recently in this forum - I > could not find an answer online. > > Best, > > Gonçalo > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.