Using write() with append=T should work. Just be careful not to open the text file with a program that will lock it while the loop is still running. Text editors will not usually lock the file so in windows you could use notepad to take a look at the output and copy/paste to somewhere else.
e.g. a <- vector(length=100000) for (i in 1:100000){ a[i]<-rnorm(1) write(a[i], "temp.txt", append=T) ## append your new bit of data to the text file at each iteration of the loop } andydol...@gmail.com 2009/4/27 Friedericksen <golu...@gmx.de> > Hey guys, > > I have a problem: I created a silly for loop without saving the results on > each step. After a while I realised that it will take days to finish the > loop until I get the results. > > Is there a way to get the data R saves in working memory or in a temporary > file while runing the loop? So that stoping the loop will not result in > complete data loss? > > Thank you very much! > > Greetings, > Friederiksen > > ______________________________________________ > 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.