I am running a multithreaded R script but I am having trouble with generating output from the cluster.
outFun <- function()
{
cat(sample(0:9,1));
}
require(snow)
clust <- makeCluster(4)
clusterExport(clust,"outFun")
clustFun <- function(i){outFun()}
clusterApplyLB(clust,1:8,clustFun)
I understand that I don't see any of the output from outFun()
because it's in a new R thread, but I was hoping that there would be some way to forward this output back to the master thread so it was visible when printed.
EDIT: This question answers this for a Linux machine, but the solution does not work for Windows. The workaround given is to simply use file output, but I am curious if anyone knows a solution to be able to actually send output back to the master thread in Windows.