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? Your suggestions are important to me. Kindly reply. Thanks in advance. Regards Divya Sarthi [[alternative HTML version deleted]]
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.
Hi,
There are many clues in the help.
First I created the file c:\sumfunction.R
x<-as.numeric(commandArgs()[-1:-4] )
print(x)
addtogether<-function(x,y){SUM<-x+y;print(SUM)}
addtogether(x[1],x[2])
Then at the command line in Windows I enter
R --vanilla --slave --args 7 10 <c:\sumfunction.R> c:\logout.txt
Regards
Alex
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of d. sarthi
maheshwari
Sent: May 16, 2007 8:29 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Running R function as a Batch process
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?
Your suggestions are important to me. Kindly reply.
Thanks in advance.
Regards
Divya Sarthi
[[alternative HTML version deleted]]
______________________________________________
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.