I have an R file test.R that I want to run on my account on a school linux server using the command:
Rscript test.RI copied R 3.1.2 into my directory on the server, which I'll call "home/mydirectory" for simpilicity.
When I run Rscript test.R I get this error:
-bash: Rscript: command not found
I tried setting the Rscript path in nano ~/.bashrc, but I don't seem to have the syntax correct.
Try 1:
export Rscript = "/home/mydirectory/R-3.1.2/bin/Rscript.exe":$RscriptTry 2:
export Rscript = "/home/mydirectory/R-3.1.2/bin/Rscript":$RscriptI also tried this command to run it directly without success.
shell_exec("/home/mydirectory/R-3.1.2/bin/Rscript") test.RAny suggestions to correctly set the path/environmental variables so that this works? Thank you.
1 Answer
Try this:
export PATH="$PATH:/home/mydirectory/R-3.1.2/bin/"Some further explanation:
Your path variable points to directories that the shell should search for commands, not directly to the path of each command. Just adding R's bin directory to $PATH is all the shell needs in order to find the Rscript program.