问题
I'm working with R for a while, and I always worked with Rstudio, I tried just now to run a Rscript command in terminal (I have a mac..) and I got this error-
>Rscript script.R
-bash: Rscript: command not found
when I tried to open R in the terminal I go the same error-
>R
-bash: R: command not found
I can run R code with the Rstudio and the R application, but I know there is a way to run R throw the terminal. Did I miss something when I installed R on my computer? do I need to add R to my PATH?
thanks in advance!
回答1:
Steps to run R script through Windows command prompt
- Set the
PATHvariable forRscript.exein the environment variables.Rscript.execan be found insidebinfolder ofR. Set the path forRscript.exeto useRscriptcommand in Windows command prompt. To check ifRscript.exehas been set environmentally or not, typeRscriptin command prompt. The follwoing message should come.
- Go to Command Prompt, set the path where your
.Rfile is there. - Run the following command: Here
abcd.Ris present underDocumentsfolder. So I set path and then runRscript abcd.R
来源:https://stackoverflow.com/questions/38456144/rscript-command-not-found