[R] command option for R CMD BATCH

Ramon Diaz-Uriarte rdiaz at cnio.es
Thu Nov 23 16:00:34 CET 2006


On Thursday 23 November 2006 15:44, Prof Brian Ripley wrote:
> Try this:
>
> gannet% cat month.R
> x <- commandArgs()
> print(x[length(x)])
>
> gannet% R --slave --args January < month.R
> [1] "January"
>


Is the above 
"R --slave --args January < month.R"
the preferred way of using it? 

I tend to use 

"R --slave < month.R January"

instead (as a consequence of reconverting former scripts that used R CMD 
BATCH). The second call produces a "ARGUMENT 'January' __ignored__" but 
otherwise seems to do the same thing. 

Thanks,

R.


> On Thu, 23 Nov 2006, Patrick Connolly wrote:
> > I wish to use R CMD BATCH to run a small R function which reads a text
> > file and plots a single graph to a PDF file.
> >
> >> version
> >
> >               _
> > platform       x86_64-unknown-linux-gnu
> > arch           x86_64
> > os             linux-gnu
> > system         x86_64, linux-gnu
> > status
> > major          2
> > minor          4.0
> > year           2006
> > month          10
> > day            03
> > svn rev        39566
> > language       R
> > version.string R version 2.4.0 (2006-10-03)
> >
> >
> > The text files are monthly data, (called lyrical names like
> > October.txt or November.txt) and the end result of each run will be a
> > PDF file called October.pdf, etc.
> >
> > It's simple enough to make a separate file for each month which has
> > the command to call the R function, e.g.  October.r would be
> > plot.month("October.txt")
> > and use it like so:
> >
> > R CMD BATCH October.r /dev/null
> > (the R function creates the name for the PDF file)
> >
> > or slightly more elegantly, a one line shell script that takes an
> > argument: R CMD BATCH $1.r /dev/null
> > (so that the script name and the name of the month will make a PDF
> > file for that month)
> >
> > What I'd like to do is avoid the need to make the Month.r files and
> > have the script pass the month information directly to the function
> > that a single .r file would call.  If I brushed up on a bit of Perl, I
> > might work out how to modify the shell script to do such a thing, but
> > I suspect it should be simpler than that.
> >
> > I had thought of using litter for such a thing, but as I looked into
> > it, I get the impression that's not the idea of litter.  (I'm also a
> > bit reluctant to recompile R.)
> >
> > Ideas welcome.
> >
> >
> > Thanks

-- 
Ramón Díaz-Uriarte
Bioinformatics 
Centro Nacional de Investigaciones Oncológicas (CNIO)
(Spanish National Cancer Center)
Melchor Fernández Almagro, 3
28029 Madrid (Spain)
Fax: +-34-91-224-6972
Phone: +-34-91-224-6900

http://ligarto.org/rdiaz
PGP KeyID: 0xE89B3462
(http://ligarto.org/rdiaz/0xE89B3462.asc)



**NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{dropped}}



More information about the R-help mailing list