Reputation: 24776
I notice that when I restart my R session all the options()
that I set are lost.
Is there a way to make the options persist across sessions? Preferably in the workspace since I want those options to be per project and not global.
options(myoption=1)
getOption("myoption") # 1
a <- 42
## close & save workspace
## start R again
getOption("myoption") # NULL, options not restored
a # 42, so workspace was restored but not the options
Upvotes: 1
Views: 227
Reputation: 24776
Seems that there is no way to do this from the R console itself.
You have to put an options(optioname=optionvalue)
in the project's .Rprofile
file. In RStudio, this file is sourced automatically when the project is opened as documented in Using Projects.
The .Rprofile
file needs to be created at the same level as the projectname.Rproj
file.
In my case the file I created ~/mytestproject/.Rprofile
contains:
options(myoption=1)
message("\n *** Loaded mytestproject .Rprofile ***\n")
It's a little inconvenient since you need to manually to keep this file in sync with the actual options()
.
Upvotes: 1