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:
munge_data.sh: line 17: --file=stats.R: command not found
Here is a snippet of the bash script:
#!/bin/bash
SCRIPTDIR=/path/to/some/directory
RBIN=`which R`
cd $SCRIPTDIR
$RBIN --file=stats.R > my.stats.output.txt # <- this is line 17 in my script
Can anyone spot what is causing this problem?