Search code examples
rconfigurationrstudio

How to run a script at the end of RStudio initialization?


I want to use my browser instead of the viewer integrated in RStudio.

In order to do that one can do:

options(viewer = NULL)

I have added this line inside my .Rprofile file but this option seems to be modified by RStudio after reading the profile script.

Is there a way to automatically run a script after the complete initialization of RStudio?


Solution

  • Try adding the following to your .Rprofile:

    # https://docs.posit.co/ide/server-pro/rstudio_pro_sessions/session_startup_scripts.html
    setHook("rstudio.sessionInit", function(newSession) {
      options(viewer = NULL)
    }, action = "append")