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.