I am executing an R script on a cluster, using the following sbatch file:
#!/bin/bash
#SBATCH --job-name=ReconstructScans
#SBATCH --mem=4g
#SBATCH --account=XXXXXX
#SBATCH --array=1-1013%5
module load StdEnv/2020
module load gcc/9.3.0
module load r/4.0.2
srun Rscript ReconstructScans.R
ReconstructScans.R calls another R script, using
source("path_to_script.R", local=FALSE)
However, for some reason, the variables declared within path_to_script.R are not accessible to ReconstructScans.R. I get the object 'DataPath' not found error.
Why might this be happening? When I open an interactive R shell and source ReconstructScans.R, everything works fine. It's when ReconstructScans.R is executed through sbatch that the problem arises.
Is it a problem with how I'm executing it using:
srun Rscript ReconstructScans.R?
Thank you,
Mrinmayi