Change graphical device at startup in RStudio

At startup, RStudio sets the default graphical device to RStudioGD. I would like the default to be X11. Putting options(device = 'X11') in .Rprofile does not work because it seems that RStudio resets the graphical device after .Rprofile is run. Is there a way to have RStudio use X11 from startup on?

You can use an RStudio session init hook in your .Rprofile. For example:

setHook("rstudio.sessionInit", function(...) {
    options(device = "X11")

This hook will be run after RStudio has completed session initialization.

1 Like

Awesome, so simple!
Is there a list of all possible hooks somewhere? I remember the help file for setHook only mentioned hooks related to package loading and attachment.
Thank you!

Unfortunately, there isn't any global list of available hooks -- these are used relatively rarely and other hooks are only sparsely documented.

We document the rstudio.sessionInit hook here, as part of the rstudioapi package:

but it would be prudent for us to document this somewhere more discoverable.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.