Re: [R] Running R function as a Batch process

From: Vladimir Eremeev <>
Date: Wed, 16 May 2007 05:06:17 -0700 (PDT)

d. sarthi maheshwari wrote:
> Hi,
> I am struggling with using R CMD BATCH command. Kindly suggest solution to
> the following problem.
> I have a function named CinC with accept two input parameters. This can be
> shown as:
> CinC <- function(start, end)
> where start and end both are character strings.
> Please suggest me how can I run this function using command R CMD BATCH.
> Currently I am trying to do like this -> R CMD BATCH c:/tt/CinC.r
> c:/tt/h.Rout -"20070416 08:41" -"20070416 10:33"
> What is wrong/incorrect with it?

You should use the function commandArgs in your code to retrieve supplied arguments from the command line.
Look at

Your R invokation should look like this
C:\> R CMD BATCH c:/tt/CinC.r c:/tt/h.Rout --args "20070416 08:41" "20070416 10:33"

And you should add something like this in your R code   command.args<-commandArgs(trailingOnly=TRUE)   CinC(command.args[1],command.args[2])

View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 16 May 2007 - 12:11:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 May 2007 - 12:31:38 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.