title: Submit jobs to a slave node from within an R script?
body: <p>To get <code>myscript.R</code> to run on a cluster slave node using a job scheduler (specifically, <a href="http://en.wikipedia.org/wiki/Portable_Batch_System" rel="noreferrer">PBS</a>)</p>
  
  <p>Currently, I submit an R script to a slave node using the following command</p>
  
  <pre><code>qsub -S /bin/bash -p -1 -cwd -pe mpich 1 -j y -o output.log ./myscript.R
  </code></pre>
  
  <p>Are there functions in R that would allow me to run myscript.R on the head node and send individual tasks to the slave nodes? Something like:</p>
  
  <pre><code>foreach(i=c('file1.csv', 'file2.csv', pbsoptions = list()) %do% read.csv(i)
  </code></pre>
  
  <hr>
  
  <p>Update: alternative solution to the qsub command is to remove <code>#/usr/bin/Rscript</code> from the first line of <code>myscript.R</code> and call it directly, as pointed out by @Josh</p>
  
  <pre><code>qsub -S /usr/bin/Rscript -p -1 -cwd -pe mpich 1 -j y -o output.log myscript.R
  </code></pre>