Reputation: 7550
I've put this in my .Rprofile
:
Sys.setenv(R_HISTSIZE='1000000')
Sys.setenv(R_HISTFILE='~/.Rhistory')
.Last <- function() {
if(interactive()) try(savehistory("~/.Rhistory"))
}
After quitting an R session, the history is written to the file, but the file is overwritten! How can I make R append to the history file instead?
Upvotes: 5
Views: 757
Reputation: 94202
After saving the history file you could use R's file read-write commands to append that history file to a different file, called whatever you like (~/.R-ancient-history
maybe?).
And R has a function for that! Try
file.append("~/.R-ancient-history","~/.Rhistory")
in your .Last
.
If you really want it all in .Rhistory
, then do file.rename("~/.R-ancient-history","~/.Rhistory")
after the append, which should do it...
All pretty well untested... That's your job!
Upvotes: 2