问题描述
我知道有关此问题有很多问题,但是我已经尝试了所有方法,我想我只是不了解命令行在Windows中的工作方式。我有一个文件保存在桌面上的文件夹中,假设:
I know there are a lot of questions regarding this issue but I've tried everything and I think I just don't understand how the command line works in windows. I have a file saved in a folder on my desktop, let's say:
C:\Users\abika_000\Desktop\R models\myfile.R
这是我的R / bin或Rscript / bin:
Here is the directory to my R/bin or Rscript/bin:
C:\Program Files\R\R-3.1.0\bin
我想使用cmd提示符运行此代码。我将如何去做呢?
I want to run this code using the cmd prompt. How would I go about doing this?
我已经尝试过以下问题的解决方案,但是无论如何我都会不断出错:
I've tried this solution from the question below but I just keep getting errors no matter what I do:
我输入的内容:
> 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 ::
向辉煌和Phil致谢。我通过输入以下内容来修复该问题:
Credit to splendour and Phil. I wound up fixing it by entering:
> "C:\Program Files\R\R-3.1.0\bin\"R CMD BATCH "C:\Users\abika_000\Desktop\R models\myfile.R"
我为这个可怜的问题表示歉意。我只是不确定如何在尝试使用R CMD BATCH或Rscript时使用cmd提示符/ directory
I apologize for the poor question. I just wasn't sure how to use the cmd prompt /directories in trying to use R CMD BATCH or Rscript
推荐答案
步骤1(如果尚未完成)是使用UNIX-y shell模拟器,例如。
I think step 1, if you haven't already done it, is to use a UNIX-y shell emulator, such as Cygwin.Then, assuming it's available on Windows (as it is on Linux/OSX), you can use the wrapper program Rscript
.
或者,如果您有UNIX-y shell模拟器,则始终可以将输入直接通过管道传递到 R
,例如:
Or, if you have a UNIX-y shell emulator, you can always pipe input straight into R
, e.g.:
R --no-save --no-restore < your_script.R
这篇关于如何从命令行运行R脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!