I have a script called foo.R that includes another script other.R, which is in the same directory:
foo.R
other.R
#!/usr/bin/env Rscript message(\
You can wrap the r script in a bash script and retrieve the script's path as a bash variable like so:
#!/bin/bash # [environment variables can be set here] path_to_script=$(dirname $0) R --slave<