How to set change default R version in RStudio Desktop with default_r_version in rstudio-prefs.json?

Specific Question:
How am I supposed to use default_r_version in rstudio-prefs.json?


  • I have multiple versions of R on my laptop
  • I would like to be able to change which version of R is the one that RStudio uses from a script
  • Since I'm using RStudio 1.3.957, it appears I can set the default value in rstudio-prefs.json
  • The documentation for that value wants an object for the value, but nothing I try seems to work

Greater Question:
I'm trying to write a script that will toggle RStudio's default R version so I don't have to open it, change it, reopen it, and wait all in between. If I'm going about this the wrong way, help me find the right way.

Thank you

Unfortunately that setting is only read by RStudio Server Pro's multiple R version support. RStudio Desktop saves R version information elsewhere (varies by OS). This article tells you where to look. What you're trying to do is not easy, but you might be able to do it by having your script change some files prior to booting RStudio.

Well, I couldn't find in there where it stores the last R version it uses. I did learn however that you can hold Ctrl on starting RStudio and it will let you choose the version of R you want to use before it starts up and that is an acceptable solution.

If you know where this data is stored, though, in the RStudio Desktop config files, I'd still like to know.

Thank you!

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