title: Using fread with foreach and doParallel in R
body: <p>I used <code>fread</code> with <code>foreach</code> and <code>doParallel</code> package in R 3.2.0 in ubuntu 14.04. The following code works just fine, even though I didn't use <code>registerDoParallel</code>.</p>
  
  <pre><code>library(foreach)
  library(doParallel)
  library(data.table)
  
  write.csv(iris,'test.csv',row.names=F)
  
  cl&lt;-makeCluster(4)
  
  tmp&lt;-foreach(i=1:10) %dopar% { t &lt;- fread('test.csv') }
  
  tmp&lt;-rbindlist(tmp)
  
  stopCluster(cl)
  </code></pre>
  
  <p>However, when switching to Windows 7 it no longer works, with or without 'registerDoParallel'. </p>
  
  <pre><code>library(foreach)
  library(doParallel)
  #library(doSNOW)
  library(data.table)
  
  write.csv(iris,'test.csv',row.names=F)
  
  cl&lt;-makeCluster(4) 
  registerDoParallel(cl)
  #registerDoSNOW(cl)
  
  tmp&lt;-foreach(i=1:10) %dopar% { t &lt;- fread('test.csv') }
  
  tmp&lt;-rbindlist(tmp)
  
  stopCluster(cl)
  </code></pre>
  
  <p>'doSNOW' package doesn't work either. Below is the error message. </p>
  
  <pre><code>Error in { : task 1 failed - "could not find function "fread""
  </code></pre>
  
  <p>Does anyone have any similar experience?</p>
  
  <p><br>
  A follow up question is regarding nested <code>foreach</code>. It seems the following won't work.</p>
  
  <pre><code>cl&lt;-makeCluster(4)
  registerDoParallel(cl)
  clusterEvalQ(cl , library(data.table))
  
  tmp&lt;-foreach(j=1:10) %dopar% {
  
              tmp1&lt;-foreach(i=1:10) %dopar% {
                            t&lt;-fread('test.csv',data.table=T)
                     }  
              rbindlist(tmp1)
        }
  stopCluster(cl)
  </code></pre>
  
  <p>　　　</p>