本文介绍了Rscript:找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在R上工作了一段时间,我一直在Rstudio上工作,我刚才尝试在终端上运行Rscript命令(我有一个Mac ..),但出现此错误-
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
当我尝试在终端中打开R时,出现相同的错误-
when I tried to open R in the terminal I go the same error-
>R
-bash: R: command not found
我可以使用Rstudio和R应用程序运行R代码,但是我知道有一种方法可以运行R抛出终端.在计算机上安装R时是否错过了某些东西?我需要在路径中添加R吗?
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?
提前谢谢!
推荐答案
通过Windows command prompt
- 在环境变量中为
Rscript.exe
设置PATH
变量.可以在R
的bin
文件夹中找到Rscript.exe
.在Windows命令提示符下,将Rscript.exe
的路径设置为使用Rscript
命令.若要检查Rscript.exe
是否已在环境上设置,请在命令提示符下键入Rscript
.将会出现以下消息.
- Set the
PATH
variable forRscript.exe
in the environment variables.Rscript.exe
can be found insidebin
folder ofR
. Set the path forRscript.exe
to useRscript
command in Windows command prompt. To check ifRscript.exe
has been set environmentally or not, typeRscript
in command prompt. The follwoing message should come.
- 转到命令提示符,设置
.R
文件所在的路径. - 运行以下命令:
abcd.R
出现在Documents
文件夹下.所以我设置了路径然后运行Rscript abcd.R
- Go to Command Prompt, set the path where your
.R
file is there. - Run the following command: Here
abcd.R
is present underDocuments
folder. So I set path and then runRscript abcd.R
这篇关于Rscript:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!