我知道关于这个问题有很多问题,但我已经尝试了一切,我想我只是不明白命令行在 Windows 中是如何工作的。我的桌面上的文件夹中保存了一个文件,比方说:
C:\Users\abika_000\Desktop\R models\myfile.R
这是我的 R/bin 或 Rscript/bin 的目录:
C:\Program Files\R\R-3.1.0\bin
我想使用 cmd 提示符运行此代码。我该怎么做呢?
我已经从下面的问题中尝试过这个解决方案,但无论我做什么,我都会不断收到错误:
从命令行运行 R 脚本 https://stackoverflow.com/questions/18306362/run-r-script-from-command-line
我输入的内容:
> R CMD BATCH C:\Users\abika_000\Desktop\R models\myfile.R
> Rscript C:\Users\abika_000\Desktop\R models\myfile.R
我得到的错误是:
'R' is not recognized as an internal or external command, operable program or batch file
'Rscript' is not recognized as an internal or external command, operable program or batch file
EDIT::
感谢辉煌和菲尔。我最终通过输入以下内容修复了它:
> "C:\Program Files\R\R-3.1.0\bin\"R CMD BATCH "C:\Users\abika_000\Desktop\R models\myfile.R"
我为这个糟糕的问题道歉。我只是不确定如何使用 cmd 提示符 /directories 来尝试使用 R CMD BATCH 或 Rscript