Krystian Radlak
2011-Jul-21 08:54 UTC
[Rd] Saving data into a text or CSV file using foreach/doSNOW
Dear list,
I am using the foreach/doSNOW packages. I want to compute some data parallel
and save results in every iteration into a text or CSV file, but then I see
in file there are some errors (some data is not saved to file and there are
empty lines). I have tested every function to append data into file and I
also tested append data to one file or more (For two processor I have saved
data into two files.), but I could solve this problem. How can I solve this
problem?
foreach(i = 1:n,.packages = "xyz") %dopar% my_function(i)
my_function(i)
{
#some code
zz <-
file(paste(cmd_args[7],toString(i%%as.numeric(cmd_args[3])),".txt",sep=""),
"at")
write(rr,file=zz)
close(zz)
}
Best,
Krystian
--
View this message in context:
http://r.789695.n4.nabble.com/Saving-data-into-a-text-or-CSV-file-using-foreach-doSNOW-tp3683155p3683155.html
Sent from the R devel mailing list archive at Nabble.com.
Krystian Radlak
2011-Jul-24 11:17 UTC
[Rd] Saving data into a text or CSV file using foreach/doSNOW
I solved this problem using Sys.getpid() function. zz <- file(paste(cmd_args[7],Sys.getpid(),".txt",sep=""), "at") write(rr,file=zz) close(zz) -- View this message in context: http://r.789695.n4.nabble.com/Saving-data-into-a-text-or-CSV-file-using-foreach-doSNOW-tp3683155p3690132.html Sent from the R devel mailing list archive at Nabble.com.