[R] Running R function as a Batch process

Vladimir Eremeev wl2776 at gmail.com
Wed May 16 14:06:17 CEST 2007




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
?commandArgs
?Startup

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: http://www.nabble.com/Running-R-function-as-a-Batch-process-tf3764048.html#a10640433
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list