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

From: Vladimir Eremeev <wl2776_at_gmail.com>
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
?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.

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.