0

I am trying to run an R script from a bash script using the Rscript command. The cluster I am on has multiple versions of R, and is telling me: "Error: This is R version 2.15.1. Package 'raster' requires >= 3.0.0. Is there a way to specify the version of R to run Rscript with?

#!/bin/sh
Rscript Test.R
MikeJewski
  • 357
  • 2
  • 13

1 Answers1

3

If you don't use a full path, then it will run the version that is found first in your $PATH variable. The solution is to either have your path have the R directory at the beginning, or to the correct path (e.g. 'alias R=/opt/my/path/R') and run the script with `shopt -s expand_aliases'

SaintHax
  • 1,875
  • 11
  • 16
  • ended up just running it from the full path. Thanks! – MikeJewski Apr 11 '16 at 19:02
  • @MikeJewski you tagged this bash, but you are running /bin/sh. shopt is a bash command. I didn't notice you are using a different shell than what you tagged. – SaintHax Apr 12 '16 at 13:29
  • I realized that after, even after putting /bin/bash, I wasn't able to get it to work. This was ultimately because I was submitting this to a cluster using the qsub command, and had to manual set it to run it using qsub -S /bin/bash. Both ways ended up working! – MikeJewski Apr 12 '16 at 13:33