title: parRapply whats wrong?
body: <p>I have a list of e-mails and I would like to compare patterns (similarity) among the rows using longest common substring to compare them.</p>
  
  <p>data is a data frame with 300.000 e-mails:</p>
  
  <pre><code>         V1
  1   "01003@163.com"
  2   "cloud@coldmail.com"
  3   "den_smukk_kiilar@hotmail.com"
  4   "Esteban.verduzco@gmail.com"
  5   "freiheitmensch@gmail.com"
  6   "mitsoanastos@yahoo.com"
  7   "ahmedsir744@yahoo.com" 
  8   ...
  </code></pre>
  
  <p>I am using this code:</p>
  
  <pre><code># Compare Strings Difference
  compare_strings = function(j,i) {
    value = as.numeric(stringdist(data[j,],data[i,],method='lcs', nthread = 2))   
    pair &lt;- rbind(data[j,], data[i,],value)
    return(pair)
  }
  
  i = 0 
  kk = 1 
  
  while(kk&lt;nrow(data)) {
  
    i = i+1 # fix row
    j = c((kk+1):nrow(data)) # rows to be compared 
  
    # Apply Function "compare_strings" for row "i" with all the others rows  
    out &lt;- as.matrix(t(apply(expand.grid(i,j),1, function(x,y)  compare_strings(x[1],x[2]))))
  
    kk = kk +1
  }
  </code></pre>
  
  <p>That works perfectly! But I have 300.000 e-mail, and I am trying to parallelize the process buy doing:</p>
  
  <pre><code>require(parallel)
  
   clus &lt;- makeCluster(2)
  
   clusterEvalQ(clus,  compare.strings &lt;- function(j,i) {
      library(stringdist)
      value = as.numeric(stringdist(data[j,],data[i,],method='lcs', nthread = 2))
      pair &lt;- rbind(data[j,], data[i,],value)
      return(pair)
    })
  
    out = as.matriz(t(parRapply(clus, expand.grid(i,j),function(x,y) compare.strings(x[1],x[2]))))
  </code></pre>
  
  <p>But I get:</p>
  
  <pre><code>Error in checkForRemoteErrors(val) : 
    2 nodes produced errors; first error: object of type 'closure' is not subsettable
  </code></pre>
  
  <p>What Am I doing wrong? Is there a better way to compare the amount of strings?</p>