title: How to use the source() function in a parallized loop (doSMP)?
body: <p>I am trying to speed up my code with a 'foreach' loop using the doSMP package.</p>
  
  <p>Here is a simplified version of my issue: I am running a file called main.R </p>
  
  <p>file: main.R:</p>
  
  <pre><code>require(doSMP)
  dropbox_path = "/home/ruser/Dropbox"
  workers &lt;- startWorkers(4)
  registerDoSMP(workers)
  foreach(jj=1:4 ) %dopar% source("test.R")
  stopWorkers(workers)
  </code></pre>
  
  <p>file: test.R:</p>
  
  <pre><code>message(dropbox_path)
  </code></pre>
  
  <p>This returns the following error:
  "Error in source("test.R") : 
    task 1 failed - "object 'dropbox_path' not found"</p>
  
  <p>If I modify main.R to be :</p>
  
  <pre><code>require(doSMP)
  dropbox_path = "/home/ruser/Dropbox"
  workers &lt;- startWorkers(4)
  registerDoSMP(workers)
  foreach(jj=1:4 ) %dopar% message(dropbox_path)
  stopWorkers(workers)
  </code></pre>
  
  <p>It then works very well. 
  It also used to work well with sequencial code ('for' instead of 'foreach').</p>
  
  <p>So R child instances can access the dropbox_path variable, but not when it is parsed through the source function. I tried to play around with the source() function arguments 'local' and 'chdir' with no sucess.</p>
  
  <p>Would you know a way for the code to work? I would like to keep using the source() function. </p>