title: Foreach loop unable to find object
body: <p>I am trying to use foreach with the parallel backend to speed up computation (of cross validation of an {AUCRF} random forest for feature selection, if this does matter). In the process of doing so i need to get a subset of a vector. The name of the vector can change but is accessible as character vector. I used the eval(parse()) construct(good idea?) to get a subset of the vector.</p>
  
  <p>Example:</p>
  
  <pre><code>library(parallel)
  library(foreach)
  library(stats)
  
  #create cluster
  clu &lt;- makeCluster(detectCores() - 1)
  registerDoParallel(clu, cores = detectCores() - 1)
  
  bar&lt;-c("a","b","c","d")
  rab&lt;-c(2,3)
  bar.name&lt;-"bar"
  
  #expected output in this example is a list containing ten times
  bar[rab]
  #or
  eval(parse(text=paste(bar.name,"[rab]",sep="")))
  
  foo&lt;-foreach(m = 1:10, .packages = c("stats")) %dopar% {
    sink("foreach.txt")
        print(bar.name)
        print(parse(text=paste(bar.name,"[rab]",sep="")))
        print(eval(parse(text=paste(bar.name,"[rab]",sep=""))))
    foo.temp&lt;-eval(parse(text=paste(bar.name,"[rab]",sep="")))
    return(foo.temp)
  }
  sink()
  stopCluster(clu)
  </code></pre>
  
  <p>However i get the following error:</p>
  
  <pre><code>Error in { : task 1 failed - "Object 'bar' not found"
  </code></pre>
  
  <p>I thought that each worker is getting a copy of the workspace with all objects. Any idea what I'm doing wrong?</p>