I tried to use BATCH command to run an input file (a simple text file) which contained a few R commands. I first saw the BATCH help page using > ?BATCH The help page mentioned the Usage as: Batch Execution of RR CMD BATCH [options] infile [outfile] The Detailed section mentioned the following: Use R CMD BATCH --help to be reminded of the usage. My input file is called batchchk, which contains the following R commands: ls() ox <- read.table("rev_full_idle.out", header=TRUE) ov <- ox$Times length(ov) summary(ov) I loaded the utils library (probably it is loaded by default): > library(utils) I ran the following commands and got the indicated errors: > BATCH batchchk Error: unexpected symbol in "BATCH batchchk" > R CMD BATCH batchchk Error: unexpected symbol in "R CMD" > R CMD BATCH --help Error: unexpected symbol in "R CMD" > BATCH --help Error: object 'BATCH' not found Can somebody please point out where I am going wrong? Thanks in advance, Manuj Connect more, do more and share more with Yahoo! India Mail. Learn more. http://in.overview.mail.yahoo.com/ [[alternative HTML version deleted]]
You probably want to use the source() command in R. R CMD BATCH is used from the command line - it's rare that people use it (unless they really know what they are doing). /Henrik On Tue, Sep 22, 2009 at 9:01 AM, Manuj Sharma <smanuj1970 at yahoo.in> wrote:> I tried to use BATCH command to run an input file (a simple text file) which contained a few R commands. > > I first saw the BATCH help page using > ???? > ?BATCH > > The help page mentioned the Usage as: > Batch Execution of RR CMD BATCH [options] infile [outfile] > > The Detailed section mentioned the following: > > Use R CMD BATCH --help to be reminded of the usage. > > My input file is called batchchk, which contains the following R commands: > ls() > ox <- read.table("rev_full_idle.out", header=TRUE) > ov <- ox$Times > length(ov) > summary(ov) > > I loaded the utils library (probably it is loaded by default): > ? > library(utils) > > I ran the following commands and got the indicated errors: > > ? > BATCH batchchk > ? ? Error: unexpected symbol in "BATCH batchchk" > > ? > R CMD BATCH batchchk > ? ? Error: unexpected symbol in "R CMD" > > ? > R CMD BATCH --help > ? ? Error: unexpected symbol in "R CMD" > > ? > BATCH --help > ? ? Error: object 'BATCH' not found > > Can somebody please point out where I am going wrong? > > Thanks in advance, > > Manuj > > > > > > > ? ? ?Connect more, do more and share more with Yahoo! India Mail. Learn more. http://in.overview.mail.yahoo.com/ > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org 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. > >
BATCH is not an R object, and it is not for use in R console. As Henrik mentioned, you should use it in the command line. Open a terminal window/command window (depending on your OS), and type "R CMD BATCH ..." there. If you are using Windows, cd to the 'bin' directory of R first (or put the 'bin' directory into your environment variable 'PATH'). Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-6609 Web: http://yihui.name Department of Statistics, Iowa State University 3211 Snedecor Hall, Ames, IA On Tue, Sep 22, 2009 at 11:01 AM, Manuj Sharma <smanuj1970 at yahoo.in> wrote:> I tried to use BATCH command to run an input file (a simple text file) which contained a few R commands. > > I first saw the BATCH help page using > ???? > ?BATCH > > The help page mentioned the Usage as: > Batch Execution of RR CMD BATCH [options] infile [outfile] > > The Detailed section mentioned the following: > > Use R CMD BATCH --help to be reminded of the usage. > > My input file is called batchchk, which contains the following R commands: > ls() > ox <- read.table("rev_full_idle.out", header=TRUE) > ov <- ox$Times > length(ov) > summary(ov) > > I loaded the utils library (probably it is loaded by default): > ? > library(utils) > > I ran the following commands and got the indicated errors: > > ? > BATCH batchchk > ? ? Error: unexpected symbol in "BATCH batchchk" > > ? > R CMD BATCH batchchk > ? ? Error: unexpected symbol in "R CMD" > > ? > R CMD BATCH --help > ? ? Error: unexpected symbol in "R CMD" > > ? > BATCH --help > ? ? Error: object 'BATCH' not found > > Can somebody please point out where I am going wrong? > > Thanks in advance, > > Manuj > > > > > > > ? ? ?Connect more, do more and share more with Yahoo! India Mail. Learn more. http://in.overview.mail.yahoo.com/ > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org 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. > >
Hi Every one, I have been struggling with a problem and need your help. I would like to automate execution of a .R file. Therefore i thought of creating a batch file. It reads @echo off start /d "C:\Program Files\R\R-2.13.1\bin\x64" R BATCH Model.R No success with running it. The command prompt flashes in and out. But I do not see results. (there is a plot command which is for testing the execution). Anyone is able to give me some advice on this. Worse than that I am not even able to get the command R BATCH Model.R to work in command prompt. I get the error "unable to open output file". Thanks Hami -- View this message in context: http://r.789695.n4.nabble.com/Problem-in-using-BATCH-command-tp902496p3910875.html Sent from the R help mailing list archive at Nabble.com.
Hi Hami This is what I use when I have run a file using the BATCH command for windows XP D:\rw\bin\R CMD BATCH --no-restore --no-save Rfile.R Rfile_log.txt where D:\rw\bin\R is your R exe file name and path Rfile.R is the R file your are "sourcing" Rfile_log.txt is the log file - handy if things go wrong. See one of the manuals I cannot remember which one - it is too late for me to remember or look it up HTH Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email Home: mackay at northnet.com.au At 12:22 17/10/2011, you wrote:>Hi Every one, > >I have been struggling with a problem and need your help. I would like to >automate execution of a .R file. Therefore i thought of creating a batch >file. It reads > >@echo off >start /d "C:\Program Files\R\R-2.13.1\bin\x64" R BATCH Model.R > >No success with running it. The command prompt flashes in and out. But I do >not see results. (there is a plot command which is for testing the >execution). > >Anyone is able to give me some advice on this. > >Worse than that I am not even able to get the command R BATCH Model.R to >work in command prompt. I get the error "unable to open output file". > >Thanks > >Hami > >-- >View this message in context: >http://r.789695.n4.nabble.com/Problem-in-using-BATCH-command-tp902496p3910875.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >R-help at r-project.org 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.