When you submit a batch job, the R script is copied to a staging area and then executed by a cluster node. This means that you must set paths explicitly in your R scripts. To set paths, add the following code to the beginning of all your R scripts. This tells R to find the absolute path to your home directory, then set the working directory to that path:
setwd(path.expand("~<username>"))
Use this code to address such problems as the following:
Loading required package: MASS Error in file(file, "r") : unable to open connection In addition: Warning message: cannot open file '<filename>', reason 'No such file or directory' Execution halted
Note: If you use a subdirectory, include the path to the subdirectory in the setwd
command referenced previously.