Beginner
Beginner

Reputation: 47

Execution of R program from CMD Windows

I am trying to run R program from Windows command line interface. I have seen earlier posts but it couldn't helped me to pass multiple arguments at a same time. Secondly, what changes i need to do in the programso that it can run from command line.

 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"

I have executed it but its giving me an error.

 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]);

Upvotes: 1

Views: 145

Answers (1)

AEF
AEF

Reputation: 5670

Commandline arguments are not automatically available as args. You need to assign them e.g. with args <- commandArgs(). In your case you are trying to subset the function args() which of course fails.

Upvotes: 1

Related Questions