I'd like to store my R
dotfiles in one central directory, similar to how one can store backups and swapfiles using vim
by including
set backupdir=$HOME/.vim/backups//
in one's .vimrc
.
My reasoning is that I sometimes want to run* R
to inspect data files in directories where I’d like to be able to count on every file in the directory being data. The result is that if I accidentally save my workspace, I have to remember to delete .Rhistory
etc. afterwards. I was hoping there would be some way to configure R
so that all of the dot files are saved in ~/R/workspace_images/
or something like that.
*: I run R
from the command line, not RStudio, although I don't think that should make a difference.
Assumming you are on linux, you may set some environment variables to control where and how many lines are saved:
The (readline on Unix-alikes) history mechanism is controlled by two environment variables:
R_HISTSIZE
controls the number of lines that are saved (default 512), andR_HISTFILE
(default ‘.Rhistory
’) sets the filename used for the loading/saving of history if requested at the beginning/end of a session (but not the default for loadhistory/savehistory). There is no limit on the number of lines of history retained during a session, so settingR_HISTSIZE
to a large value has no penalty unless a large file is actually generated.
from ?utils::savehistory