Creating a list to store output objects from a recursive loop
On 09.11.2010 09:51, Santosh Srinivas wrote:
Dear Group, I am having a function that I am running in a loop that generated two results for each loop The result1 is a zoo object The result2 is a data frame Now I want to put both of them in a list
Just generate a list of lists, the latter list each containing one zoo object and 1 data.frame. Or use a list with dim attributes, so that it is like the matrix you gave below. Uwe Ligges
or some structure ... that I can
access or output to a file after the loop is done.
For e.g.
for (i in 1:20){
niceFunction(x[i],i)
}
niceFunction (x,i) {
result1 = someOperations() #zoo object
result2 = someOperations() #data.frame
OutputObj[i,1]=result1
OutputObj[i,2]=result2
}
How can I go about this?
Thanks,
S
______________________________________________ R-help at 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.