[R] R as shelll script

From: Alexandre Aguiar <asaguiar_at_spsconsultoria.com>
Date: Tue, 27 May 2008 21:28:09 -0300


Hi,

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).

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 :-).

Thanx for the existance of this list.

Alexandre

-- 
Alexandre Santos Aguiar, MD, SCT
--
website: http://spsconsultoria.com/
Phone: +55-11-3717-4866 (SP)
Phone: +55-21-3717-4866 (RJ)
Voicemail: +55-11-2157-6891 (SP)
Fax: +55-11-5549-8760 (SP)
--

______________________________________________
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 - 01:11:30 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