How to update R and RStudio?

Learn how to update R and RStudio

Regular updates bring new features and ensure that you’re benefiting from bug fixes and performance improvements. In this blog post, we’ll guide you through the process of updating R, ensuring your statistical arsenal remains sharp and ready for any data challenge.

Why to update R?

There are many reasons why you would like to keep R updated, such as:

  • Bug Fixes and stability: updates often come with bug fixes, addressing issues that might affect your analyses.
  • Performance improvements: each update aims to enhance the efficiency of R, making your code run smoother and faster.
  • New features: exciting new features and functionalities are introduced with each version, expanding the capabilities of R.
  • Package compatibility: new R versions ensure compatibility with the latest packages, preventing any issues when you try out cutting-edge statistical techniques.

How to check which are the new features?

As stated before, a new version of a software provides enhancements and bug corrections.

  • For R updates check the following link from CRAN showing the news about the latests R versions available, including new features, utilities and fixed bugs:

  • For RStudio updates you can go to the following link to check for new features and fixed bugs:

Checking these sites before updating R is relevant to understand the main changes and to verify if an issue you might be experiencing is now solved.

Step-by-step guide to update R

Check your current versions

The first step is to check your current R version. For this purpose you will need to open R and read the first line that appears on the console messages or type R.version.string to see the version number.

"R version 4.3.2 (2023-10-31 ucrt)"

Now, you will have to check if that version is the latest version available on CRAN. If not, you might consider updating your R version.

Check the latest R version on CRAN to verify if an update is needed

If you want to learn more about how to check the R version read the tutorial about checking which R version is running on your computer.

Download and install the latest R version

If your R version doesn’t match the latest version and you want to update it, close R, navigate to CRAN and download the appropriate version for your operating system. Then, follow the simple installation instructions.

Update R for your operating system

If you need further guidance about the process of downloading and installing R from CRAN check the tutorial about installing R on Windows, Mac or Linux.

Once updated, open R again and verify that you are running the latest version.

Update packages

After updating R, it is recommended to open it and before executing anything run the following command in your R console to update your installed packages:

update.packages(ask = FALSE, checkBuilt = TRUE)

Alternatively, you can go to the Packages pane and press Update:

Search for R package updates

Then, a new window will arise with the packages that need an update. You can select them and press Install Updates.

R packages to be updated

Although it is not always necessary to run update.packages() after upgrading R, it is a good practice to do so, especially if you are performing a major upgrade. This ensures that your packages are up to date and optimized to work with the most recent version of R.

Update R using installr package (only for Windows)

The installr package simplifies the update process, making it more user-friendly, but only on Windows. First, you will need to install installr and load it into your R session.

# Install and load "installr"

Now you can simply use the updateR function:

# install.packages("installr")

# Function to update R

Once the updateR function is executed, it will guide you through the update process, automatically detecting your current R version. If necessary, it will download the latest version and prompt you to move packages from the old folder to the new one or to update packages. The function takes the following steps:

  • Detection of current R version.
  • Comparison with latest version.
  • Guidance through the update process.
  • Prompt for package migration.
  • Open new R.
  • Close session of old R.

Note that it is possible to customize some arguments of the function, such as update_packages to specify that you want or you don’t want to take a specific step instead of asking. Read the documentation of the function with ?updateR for further details.

# Install and load "installr"

# Function to update R
updateR(update_packages = FALSE)

Step-by-step guide to update RStudio

Check your current RStudio version

To check for the current RStudio version installed on your computer you will have to follow these steps:

  • Open RStudio.
  • In the menu bar at the top of the RStudio window, click on Help.
  • From the drop-down menu, select About RStudio.

Check RStudio version

  • A new window will appear, displaying information about your RStudio version, including the version number.

Check RStudio version

  • The version number is typically listed at the top of the About RStudio window. You can copy the version if needed with Copy Version button.

Note that to verify if you need an update you can also click over Check for Updates.

If you haven’t updated RStudio in a while, a window will appear indicating that a new version of RStudio is available.

Download and install latest RStudio version

Updating RStudio is straightforward. You will need to go to:

  • Download the latest version of RStudio
  • Close RStudio if open.
  • Run the installer.
  • Open RStudio again.

Change between different R versions

It is possible to change between different R versions. For this you have to follow these steps:

  • In the menu bar at the top of the RStudio window, click on Tools.
  • From the drop-down menu, select Global Options.
  • Select General.
  • Change the R version.

Change R version RStudio

This option will also help you to verify which version is running on RStudio.