Re: [R] R as shelll script

From: Dirk Eddelbuettel <edd_at_debian.org>
Date: Wed, 28 May 2008 01:16:15 +0000

On Tue, May 27, 2008 at 09:28:09PM -0300, Alexandre Aguiar wrote:
> I have devised some applications of R as a scripting shell language and
> started using it flawlessly a few months ago.
>
> Never minded publishing it because it looked so obvious. However, a search
> in the archives revealed there is no recent easy-to-use method proposed.
> The latest reference I found is from 2006
> (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81124.html) and even a c
> wrapper has been proposed
> (http://kavaro.fi/mediawiki/index.php/Using_R_from_the_shell).

But there are known scripting solutions:

  i) littler was released in the summer / fall of 2006

  ii) Rscript appeared with R 2.5.0 in the spring of 2007  

> So, here it goes an exceedingly simple example of my simple solution that
> works pretty well:
>
> #!/usr/local/bin/Rscript --vanilla
> update.packages(ask=F, repos="http://cran.spsconsultoria.com")
> # no need for calls to quit()
>
> Now just chmod this properly (at least 700 is advisable) and you have an
> executable that can be run directly from the command line.
>
> The --vanilla option is important to avoid dissemination of .History
> and .Rdata files in the system. But one can replace for another set of
> options to allow the load of .Rprofile, for instance (by
> using "--no-save --no-restore --no-site-file --no-environ" instead).
>
> This has worked to me under several flavors of Linux and R since 2.2 or 2.4,
> not sure, do not remember (it must be that german guy the doctor said I
> can't remove from my mind :-).

As you are using Rscript, this can't have worked with R 2.2.* or 2.4.*.

Dirk

-- 
Three out of two people have difficulties with fractions.

______________________________________________
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.
Received on Wed 28 May 2008 - 03:37:55 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 28 May 2008 - 04:30:43 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.

list of date sections of archive