Skip to content

Can one set --no-save in .Rprofile

2 messages · Michael M. Meyer, Thomas Lumley

#
Thanks to Brian Ripley and Robert Gentleman
who both suggested  adding

rgentlem at jimmy.harvard.edu said:
to the .Rprofile.

While this works (and I might use it), it is not as clean as I would 
like.  For instance, with this profile, if I subsequently run
	R --save
the "--save" will be ignored.

It would seem a good solution might be to allow something in the 
environement (or .Renvironment file) like

	R_OPTIONS = "--nosave --noreadline ..."

One could then (logically) parse those options  before the command line is read, 
and have the command line override anything set in the R_OPTIONS 
string.  The one wrinkle is the --no-init-file option.  So I guess the 
logic has to go something like.
1) Read command line args (and save them somewhere).
2) if(exists(.Rprofile) and we should read it)  parse that file.
3) re-parse command line options to override the init file.

If one were to go this route, then one probably needs a
	--save-ask
command line option, to restore the default behaviour.

Maybe this is getting too complicated, and I'll just write my little 
wrapper function,

#!/bin/sh
if ([ -f .Roptions ]) then
  exec R `cat .Roptions` $*
elif ([ -f $HOME/.Roptions ]) then
  exec R `cat $HOME/.Roptions` $*
else
  exec R $*
fi



Mike Meyer, Salter Point Associates, Seattle WA


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 18 Jan 2001, Michael M. Meyer wrote:

            
You can get around this using commandArgs() to find out if --save was
specified (at least on Unix, I haven't checked on Windows)

Define qsave() and qnosave() as quit functions with the
"no" and"yes" defaults and then

if (match("--save",commandArgs(),FALSE))
	q<-qsave
else
	q<-qnosave

  -thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._