Closed HenrikBengtsson closed 6 years ago
Restarting R can be done using something like:
restart_r <- function(status = 0, debug = TRUE) {
if (debug) message("restart_r(): Customizing .Last() to relaunch R ...")
assign(".Last", function() {
args <- commandArgs()
system2(args[1], args = args[-1])
}, envir = globalenv())
if (debug) message("restart_r(): Quitting current R session and starting a new one ...")
quit(save = "no", status = status, runLast = TRUE)
}
Source: https://stackoverflow.com/a/43792584/1072091
Note also that RStudio has a .rs.restartR()
.
Triggered by discussion in Bioc-devel thread 'How to recreate R CMD BUILD environment in interactive session?' on 2017-10-23, I might be helpful if the startup package provides a way to emulate certain startup configuration such as:
R CMD build
R CMD install
R CMD check
For instance, from above Bioc-devel thread mention that
R CMD build
ends up running R as:Some ideas on the API for preset configs:
and
with
startup::startup()
in .Rprofile.Maybe one could relaunch an R session by:
which will create a one-time Rprofile file containing
startup::startup(as = "R CMD build")
usingR_PROFILE_USER
or similar.UPDATE 2017-10-26: It looks like the
startup::restart()
idea is sufficient.