title: load does not work with foreach and %dopar%
body: <p>I encountered some issues with using foreach %dopar% when loading objects from disk into memory... Objects are not loaded when I try to load them when using foreach %dopar% (it works when I use only %do%) Below is a simple example that shows my problem.</p>
  
  <pre><code>envir = .GlobalEnv
  
  x &lt;- "X test"
  y &lt;- "Y test"
  z &lt;- "Z test"
  
  save(x, file="x.RData")
  save(y, file="y.RData")
  save(z, file="z.RData")
  
  rm(x)
  rm(y)
  rm(z)
  
  objectsNamesVector &lt;- c("x", "y", "z")
  
  foreach(i=1:length(objectsNamesVector), .combine=function (...) NULL,    .multicombine=TRUE) %do% {
      print(paste("Loading object ", objectsNamesVector[i]," - ", i, " of ",    length(objectsNamesVector), sep=""))
      load(file=paste(objectsNamesVector[i], ".RData", sep=""), envir=envir)
  }
  
  print(x)
  print(y)
  print(z)
  
  rm(x)
  rm(y)
  rm(z)
  
  foreach(i=1:length(objectsNamesVector), .combine=function (...) NULL, .multicombine=TRUE) %dopar% {
      print(paste("Loading object ", objectsNamesVector[i]," - ", i, " of ", length(objectsNamesVector), sep=""))
      load(file=paste(objectsNamesVector[i], ".RData", sep=""), envir=envir)
  }
  
  print(x)
  print(y)
  print(z)
  </code></pre>
  
  <p>Result of executing this code is(without the ">"):</p>
  
  <pre><code>envir = .GlobalEnv
  
  x &lt;- "X test"
  y &lt;- "Y test"
  z &lt;- "Z test"
  
  save(x, file="x.RData")
  save(y, file="y.RData")
  save(z, file="z.RData")
  
  rm(x)
  rm(y)
  rm(z)
  
  objectsNamesVector &lt;- c("x", "y", "z")
  
  foreach(i=1:length(objectsNamesVector), .combine=function (...) NULL,    .multicombine=TRUE) %do% {
  +   print(paste("Loading object ", objectsNamesVector[i]," - ", i, " of ", length(objectsNamesVector), sep=""))
  +   load(file=paste(objectsNamesVector[i], ".RData", sep=""), envir=envir)
  + }
  [1] "Loading object x - 1 of 3"
  [1] "Loading object y - 2 of 3"
  [1] "Loading object z - 3 of 3"
  NULL
  
  print(x)
  [1] "X test"
  print(y)
  [1] "Y test"
  print(z)
  [1] "Z test"
  rm(x)
  rm(y)
  rm(z)
  
  foreach(i=1:length(objectsNamesVector), .combine=function (...) NULL, .multicombine=TRUE) %dopar% {
  +   print(paste("Loading object ", objectsNamesVector[i]," - ", i, " of ", length(objectsNamesVector), sep=""))
  +   load(file=paste(objectsNamesVector[i], ".RData", sep=""), envir=envir)
  + }
  NULL
  
  print(x)
  Error in print(x) : object 'x' not found
  print(y)
  Error in print(y) : object 'y' not found
  print(z)
  Error in print(z) : object 'z' not found
  </code></pre>
  
  <p>I understand that I cannot improve IO with foreach since IO is sequential on my architecture. I would just like to understand why this is not working...</p>
  
  <p>Thank you for your answer.</p>
  
  <p>Regards,
  Samo.</p>