Change R Version in RStudio: A Quick How-To

In this post, we will learn how to Change the R Version in RStudio. Knowing how to change the version of R in RStudio might be handy if you have to use packages not available in the most common version of R. Switching the version of R is quite simple; therefore, this post will be a short one. Before we proceed with the steps to change the R version, let us quickly check the current R version you are running. One way to see the version of R you are running is to execute the following code in your R console:

R.version$version.string
Code language: PHP (php)

In this example, we can see that we are running R version 4.3.1:

  • Save

Additionally, it may be good to ensure you have the latest R version installed (to update R, you can use the updateR() function from the installr package). Now, let us move on to the following section, where we will walk through the straightforward steps to switch R versions seamlessly within RStudio.

Table of Contents

How to Change R Version in RStudio in 4 Steps

We can effortlessly change the R version in RStudio in four simple steps to accommodate our needs. Here are the four steps:

1. Access Global Options:

We start by navigating to the “Tools” menu at the top of the RStudio interface. Here is the dropdown menu we get when clicking on “Tools”:

first step to changing R version in RStudio is to open the Global Options
  • Save

Click on “Global Options,” which opens a window with various customization settings. Here, we can, among other things, choose among the installed versions of R.

2. Navigate to R Sessions:

Navigate to R Sessions: Within the Global Options window, locate and click on the “General” category on the left sidebar. Under “R Sessions,” there is an option to “Change…”

the second step to changing version of R in RStudio is to click "Change..."
  • Save

Click on the button to open a new pop-up window and continue to the next step.

3. Choose Specific R Version:

As previously mentioned, a new window will appear. Opt for “Choose specific version of R” and click on the desired R version installed on your system.

the third step is to choose the specific version of R you want to change to.
  • Save

Confirm your selection by clicking “OK.”

4. Restart RStudio:

After choosing the specific R version, we must restart RStudio to implement the changes fully. Note that we can see this in the pop-up message we also get in RStudio:

  • Save

Close and reopen RStudio to ensure the new R version is in effect. If we run the R.version$version.string command again after restarting RStudio, we can now see that we have successfully changed R version in RStudio! Here is an example image from running that command (compare to the previous image, in the beginning of the post):

  • Save

Conclusion: Change R Version in RStudio

In this tutorial, we have learned how to change the R version in RStudio. Changing the R version may be valuable for providing reproducibility and adapting to package requirements. As we learned, there are four easy steps, from accessing Global Options to restarting RStudio to change the version of R within RStudio.

Understanding how to change the R version is advantageous for projects requiring specific package versions or dealing with compatibility issues. Reproducibility, a cornerstone in data analysis and research becomes more attainable when researchers switch between R versions to maintain consistency in their analyses.

Notably, this method offers flexibility, allowing users to install different R versions before making the switch.

If you find the information in this post valuable, please consider referencing it in your reports or papers. Please share this post with your peers, colleagues, and fellow researchers.

  • Save

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Share via
Copy link
Powered by Social Snap