title: Running R batch script in a bash script
body: <p>I am trying to run a batch script (set of R commands saved in a file), from a bash script. For some reason, the statement in the bash script that runs the R script works when I type it manually on the command line, however when the statement is executed in the batch script it fails with the error:</p>
  
  <p><strong>munge_data.sh: line 17: --file=stats.R: command not found</strong></p>
  
  <p>Here is a snippet of the bash script:</p>
  
  <pre><code>#!/bin/bash
  SCRIPTDIR=/path/to/some/directory
  RBIN=`which R`
  
  cd $SCRIPTDIR
  
  $RBIN --file=stats.R &gt; my.stats.output.txt # &lt;- this is line 17 in my script
  </code></pre>
  
  <p>Can anyone spot what is causing this problem?</p>