rprofile stream-lines project .Rprofile configuration loading.
rprofile is on CRAN. Install it via
install.packages('rprofile')or install the development version from my R-Universe via
install.packages('rprofile', repos = 'https://klmr.r-universe.dev')To use the package, call rprofile::install() in the directory of your project to add the following as the first line in the project .Rprofile file:
try(rprofile::load(), silent = TRUE)In most cases, that’s it. See the documentation for available parameters to customize the configuration, or have a look at this project’s own .Rprofile file.
At the moment, rprofile performs the following actions, in order, unless disabled via arguments:
- If the project is using an renv environment, it will be activated.
- If the project contains a
.envfile in its current path, it will be loaded viareadRenviron(). - The user profile (that is, the file
~/.Rprofile, or a file set via theR_PROFILE_USERenvironment variable) is loaded. Any errors that occur while loading this file will be converted into warnings, andrprofile::load()will invisibly return whether the file loaded without errors. - If the project is an R package, load it via
pkgload::load_all(export_all = FALSE). To avoid disrupting the regular package load order, this action will be deferred until after all default packages (given bygetOption('defaultPackages')) have been loaded and attached.