How to store nested for loop data in r before exporting with write.table

298 Views Asked by At

I have several nested for loops in which am currently appending a write.table every iteration. The following example is basic but should convey what I am trying to do...

for (i in 1:10){
  for (j in 1:10){
    for (k in 1:10){
      Data <- data.table(i+j+k)
      write.table(Data, append_TRUE, file = paste(Temp,".csv",sep"")
}}}

My "Data" query is much more complex than what I have show and every iteration is very slow appended to the file. Is there a way to save the "Data" in the workspace before writing (exporting) the data out.

0

There are 0 best solutions below