1

I use a separate installation of R for each project. To make RStudio use the right one I click and hold down the Control key when I start RStudio. This opens a "Choosing R Installation" pop-up where I can select the R binary I need.

The problem is that - unlike in this RStudio support article - the pop-up shows only the very last version of R that I used. So whenever I switch projects I have to browse to the R binary that I need.

Is there a way to make RStudio remember the other R versions I've used?

If there isn't, where does RStudio look for the last used one? If I knew that, I could probably use a script to overwrite it before launching RStudio.

Some details:

  • I am on Windows 7/10.
  • RStudio version is 1.3.1093
  • None of the registry keys described here are set.
4
  • I believe RStudio just uses whichever version of R that was last used when you open the software.
    – Phil
    Nov 23, 2020 at 15:14
  • @Phil, thanks for commenting. RStudio instructions (support.rstudio.com/hc/en-us/articles/…) on using different R versions have a screenshot that contains multiple options to choose from. This might have changed in some RStudio update, or maybe the screenshot was not actually taken on Windows. So you might be right, of course. In this case, I would like to know where RStudio stores the information about the last used version of R - I could then just overwrite it.
    – Evgenii
    Nov 24, 2020 at 10:02
  • I think filing an issue on RStudio's GH repo would be the most efficient way of finding out.
    – Phil
    Nov 24, 2020 at 15:12
  • Thank you for the idea, @Phil! RStudio's GitHub issue tracker suggested that questions should be asked at RStudio Community - which is what I did. Here is the link if anyone is interested: community.rstudio.com/t/…
    – Evgenii
    Nov 25, 2020 at 7:49

1 Answer 1

0

Since you mentioned that you kept the registry clean and under the assumption that you are using distinct/separate folders for each of your projects one COULD be tempted to try something like

  • a .Renviron file containing R_HOME=C:/path/to/your/required/version or
  • a .Rprofile file containing Sys.setenv(R_HOME='path/to/your/version')

in your project folder(s)?
Or potentially put a .bat file in there with content like

SET R_HOME=Path/to/your/R.version
cd /D "%~dp0"
start .YourProject.Rproj

BUT NOPE! Currently this type of functionality/behaviour is NOT available for RStudio Desktop Free (as of time of writing this is RStudio Desktop 1.3.1093) BUT can only be achieved with RStudio Server PRO - see 6.3.3 User Configurable Default Version.

@Evgenil: updated answer based on your suggestion and after I had the time to test the idea as well

3
  • Thank you for the suggestion, @GWD. I'll try this today.
    – Evgenii
    Nov 27, 2020 at 7:51
  • 1
    The .Renviron solution did not work. R.home() returns the path specified in the .Renviron file but it is not where r sessions are started from. Both looking into the RStudio options and using R.Version() show that it is the last r version that is still being used. I think your answer should be updated with this information because it might look like it worked while it actually doesn't. I don't meat to be ungrateful, I just worry about other people using your answer without checking.
    – Evgenii
    Nov 27, 2020 at 10:23
  • Setting R_HOME in the terminal has the same effect (R.home() is changed but not which R binary is used).
    – Evgenii
    Nov 27, 2020 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.