Re: [R] command option for R CMD BATCH

2006-11-24 Thread Ramon Diaz-Uriarte
Thanks.

R.

On Thursday 23 November 2006 16:32, Prof Brian Ripley wrote:
 On Thu, 23 Nov 2006, Ramon Diaz-Uriarte wrote:
  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?

 Yes it is.  That's exactly what --args was added to allow.

  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.

-- 
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}}

__
R-help@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.


[R] command option for R CMD BATCH

2006-11-23 Thread Patrick Connolly
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  
day03  
svn rev39566   
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

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@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.


Re: [R] command option for R CMD BATCH

2006-11-23 Thread Vladimir Eremeev
Patrick Connolly p_connolly at ihug.co.nz writes:

 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.  

 ?commandArgs

__
R-help@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.


Re: [R] command option for R CMD BATCH

2006-11-23 Thread Prof Brian Ripley
Try this:

gannet% cat month.R
x - commandArgs()
print(x[length(x)])

gannet% R --slave --args January  month.R
[1] January


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
 day03
 svn rev39566
 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



-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] command option for R CMD BATCH

2006-11-23 Thread Ramon Diaz-Uriarte
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
  day03
  svn rev39566
  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}}

__
R-help@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.


Re: [R] command option for R CMD BATCH

2006-11-23 Thread Prof Brian Ripley
On Thu, 23 Nov 2006, Ramon Diaz-Uriarte wrote:

 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?

Yes it is.  That's exactly what --args was added to allow.

 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.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] command option for R CMD BATCH

2006-11-23 Thread Patrick Connolly
On Thu, 23-Nov-2006 at 02:44PM +, 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

That's exactly what I needed.  Thank you Brian for a concise and
thorough answer.



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@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.