Using Rscript in Linux server

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.R

I copied R 3.1.2 into my directory on the server, which I'll call "home/mydirectory" for simpilicity.

enter image description here

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":$Rscript

Try 2:

export Rscript = "/home/mydirectory/R-3.1.2/bin/Rscript":$Rscript

I also tried this command to run it directly without success.

shell_exec("/home/mydirectory/R-3.1.2/bin/Rscript") test.R

Any 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.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like