Options
You can add the options
script to your .Rprofile
.
One of the easiest ways to access this is through the usethis
library, specifically:
usethis::edit_r_profile()
The .Rproflie
is always run at the start of a new session unless specifically told otherwise.
However, I only give you this with a MAJOR warning - adding code into your .Rprofile
will prevent your R code from being reproducible. For this reason, I would strongly recommend you set the options
call in a snippet in RStudio instead of using the .Rprofile
, allowing for a keyboard shortcut to easily add to any script you run. While perhaps less convenient, I believe it's well worth the trade-off to keep your code fully reproducible. You can find more info on snippets with this support article from RStudio.
Envars
The Sys.setenv
call would probably be suited well for using a .Renviron
file.
Again, easily added with:
usethis::edit_r_environ()
Here is a nice reference to better explain the full use of .Rprofile
and .Renviron
files: https://cfss.uchicago.edu/notes/r-startup/