savehistory directories and quitting R (PR#2038)
Mark.Bravington@csiro.au
Mark.Bravington@csiro.au
Tue, 22 Oct 2002 10:41:39 +1100
Thanks-- as Duncan Murdoch also noted, R_HISTFILE can be used to solve my
problem, as below. BTW it's not easy to find out about R_HISTFILE in the
help system or manuals, though, unless you already know it exists-- it only
seems to be described under startup options, not things to do with history.
However, Duncan's reply did hint at an inconsistency, in that savehistory()
defaults to using a file called .Rhistory in getwd(), rather than using
R_HISTFILE. I've modified my savehistory to default to R_HISTFILE if it
exists, like so:
savehistory_ function( file) {
if( missing( file) && is.null( file <- Sys.getenv( 'R_HISTFILE')))
file <- '.Rhistory'
get( 'savehistory', pos='package:base')( file)
}
#This is not a bug. If you override a system function, you
#can't expect it
#to be used by R internals. Indeed, as from 1.6.0 you can't
#even expect it
#to be used by R's base functions, due to namespaces.
With an eye to namespace-like issues, I originally put some code in .First
to overwrite the version of savehistory within package:base, rather than
simply masking it with a copy in .GlobalEnv. But, since savehistory wasn't
actually called at quit time, even that didn't fool the system...
cheers
Mark
*******************************
Mark Bravington
CSIRO (CMIS)
PO Box 1538
Castray Esplanade
Hobart
TAS 7001
phone (61) 3 6232 5118
fax (61) 3 6232 5012
Mark.Bravington@csiro.au
#-----Original Message-----
#From: ripley@stats.ox.ac.uk [mailto:ripley@stats.ox.ac.uk]
#Sent: Tuesday, 15 October 2002 12:31 AM
#To: Mark.Bravington@csiro.au
#Cc: r-devel@stat.math.ethz.ch; R-bugs@biostat.ku.dk
#Subject: Re: savehistory directories and quitting R (PR#2038)
#
#
#This is not a bug. If you override a system function, you
#can't expect it
#to be used by R internals. Indeed, as from 1.6.0 you can't
#even expect it
#to be used by R's base functions, due to namespaces.
#
#There are very good reasons for the internal quit code not to
#call user's
#R code, the main one being that R errors will not be handled then.
#.Last is made available as a hook to enable you to do what you want:
#as the help page says.
#
#Doesn't setting R_HISTFILE do this for you automatically? Just set
#R_HISTFILE="D:/R50/.Rhistory" and the history should be loaded
#and saved
#to the specified place. Works under Unix, at least.
#
#
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._