[英]run R script from .bat (batch file)
I am trying to run ar script using batch file. 我正在尝试使用批处理文件运行ar脚本。 Currently I am using
start"" "shortcut of R"
to open R. However, I wanna R automatically run ar script that I have saved on the computer. 目前我正在使用
start"" "shortcut of R"
打开R.但是,我想R自动运行我已保存在计算机上的脚本。
Possibly R will be closed after running the script and user do not see R running. 可能在运行脚本后R将关闭,用户看不到R正在运行。
Is that possible? 那可能吗? Thanks a lot!
非常感谢!
Rscript is a non-interactive variant of the standard R command, just designed for this kind of use. Rscript是标准R命令的非交互式变体,仅为此类用途而设计。
For example, under windows you can define a launcher.bat
like this : 例如,在windows下你可以像这样定义一个
launcher.bat
:
PATH PATH_TO_R/R-version/bin;%path%
cd PATH_TO_R_SCRIPT
Rscript myscript.R arg1 arg2
In myscript.R you add the code to read the arguments: 在myscript.R中,您添加代码以读取参数:
args <- commandArgs(trailingOnly = TRUE)
arg1 <- as.character(args[1])
arg2 <- as.numeric(args[2])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.