title: writing to global variables in using doSNOW and doing parallelization in R?
body: <p>Is there a problem when accessing/writing to global variable in using doSNOW package on multiple cores?</p>
  
  <p>In the below program, each of the MyCalculations(ii) writes to the ii-th column of the matrix "globalVariable"...</p>
  
  <p>Do you think the result will be correct? Will there be hidden catches?</p>
  
  <p>Thanks a lot!</p>
  
  <p>p.s. I have to write out to the global variable because this is a simplied example, in fact I have lots of outputs that need to be transported from within the parallel loops... therefore, probably the only way is to write out to global variables...</p>
  
  <pre><code>library(doSNOW)
  MaxSearchSpace=44*5
  globalVariable=matrix(0, 10000, MaxSearchSpace)
  cl&lt;-makeCluster(7)
  registerDoSNOW(cl)
  foreach (ii = 2:nMaxSearchSpace, .combine=cbind, .verbose=F) %dopar%
    {
     MyCalculations(ii)
    }
  
  stopCluster(cl)
  </code></pre>
  
  <p>p.s. I am asking - within the DoSnow framework, is there any danger of accessing/writing global variables... thx</p>