Not sure if it's the best way, but you could do it this way: all.results <- vector(mode="numeric") for (i in 1:100) { ... this.run <- ... all.results <- c(all.results,this.run) } At this point all.results contains the values of this.run from the whole loop. If this.run is not a vector/number but a data frame look at rbind/cbind.
Or, create a vector/matrix first and then populate it from the for loop: all.results <- vector()/matrix()/data.frame() for (i in 1:100) for(j ...) { ... all.results[i] <- this.run ,OR all.results[i,] <- this.run , OR all.results[i,j] <- this.run } HTH, b. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 14, 2004 2:44 PM To: [EMAIL PROTECTED] Subject: [R] Re : Save result in a For Loop Hiya, I have been struggling to save the result from the FOR loop. What is the best way to do it, as I need the result to merge with another dataset for further analysis ? for (dd in ((M-10):M)){ + dist<-(32-dd) + r<-1/2*(1-exp(-2*dist/100)) + map<-c(dd,round(r,4)) + print(map) + next + } Thanks. Stella ___________________________________________________________________________ This message, including attachments, is confidential. If\ yo...{{dropped}} ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html