我正在尝试从Windows命令行界面运行R程序。我之前看过帖子,但它无法帮助我同时传递多个参数。其次,我需要在程序中进行哪些更改,以便它可以从命令行运行。
Statement on CMD look like this;
C:\Program Files\R\R-3.3.3\bin\i386> Rscript
C:\Users\Public\Command_Line.R "2017-07-04 14:13:25", "2017-07-04 15:36:40", "0000-0000-0000-0000","1","0"
我已经执行了它,但它给了我一个错误。
C:\Program Files\R\R-3.3.3\bin\i386> Rscript C:\Users\Public\Command_Line.R "2017-07-04 14:13:25", "2017-07-04
15:36:40", '0000-0000-0000-0000', 1, 0
Loading required package: methods
Error in args[1] : object of type 'closure' is not subsettable
Calls: subset -> subset.data.frame -> eval -> eval
Execution halted
Actual program is mentioned below;
args<-commandArgs(FALSE)
xsub <- subset(d, d$properties$appuserid == args[3] &
d$properties$devicedate >= args[1] &
d$properties$devicedate <= args[2] &
d$properties$location$building == args[4] &
d$properties$location$floor == args[5]);
答案 0 :(得分:0)
命令行参数不会自动显示为args
。你需要分配它们,例如与args <- commandArgs()
。在您的情况下,您正在尝试将函数args()
进行子集化,这当然会失败。