How to Update R on RStudio

Deepanshu Bhalla Add Comment

This tutorial explains multiple methods to update R.

Method 1: Update R Automatically

R can be easily updated with "installr" package. To update R on MacOS, you need to use "updateR" package instead of "installr" package.

Windows: installr

install.packages("installr")
library(installr)
updateR() 

Mac: updateR

install.packages("devtools")
devtools::install_github("AndreaCirilloAC/updateR")
updateR(admin_password = "PASSWORD") # Where "PASSWORD" stands for your system password

The dialog box will be opened to take you through the following steps -

  1. It checks for a newer version of R.
  2. If one exists, the function will download the most updated R version and run its installer.
  3. Once done, the function will offer to copy (or move) all of the packages from the old R library to the new R library.
  4. It will then offer to update the moved packages, offer to open the new Rgui, and lastly, it will quit the old R.

Method 2: Install and Update R Manually

  1. Go to the CRAN website.
    For Windows Users - https://cran.r-project.org/bin/windows/base/.
    For Mac Users - https://cran.r-project.org/bin/macosx/
  2. Download the latest R installer.
  3. Run the installer, and it will guide you through the installation process.
  4. After updating R, open RStudio. Close RStudio if it is already opened and open it again.
  5. RStudio will automatically detect the updated R version. Run this command R.version.string to check the R version RStudio is using. If the new R version is not appearing, please follow the steps below. Otherwise, your R has been updated successfully.
  6. In RStudio, Go to "Tools" in the top menu and select "Global Options".
  7. In the "Global Options" dialog box, click on "General" on the left panel.
  8. Look for the "R version" section on the right panel.
  9. Click on the "Change" button next to "R version".
  10. Select the appropriate version of R
  11. Click "OK" to close the "R Version Chooser" dialog.
  12. Click "Apply" and then "OK" to close the "Global Options" dialog.

Next step is that you need to install all the R packages again. Follow the steps below to do it quickly.

  1. Move the packages from your old R version to the new one:
    • Navigate to the directory where your R packages are installed.
    • Locate the folder of your old R version, typically found in
      Windows - C:\Users\YourUsername\Documents\R\win-library\x.x
      MacOS - /Library/Frameworks/R.framework/Versions/x.xx/Resources/library
    • Copy all the folders containing your packages from the old R version directory, excluding the base packages that are already present in the new R version.
    • Paste these folders into the corresponding directory of the new R version, replacing x.xx with the old and new R version at a time.
  2. Update the moved packages:
    • Open R and run the following command:
    • update.packages(checkBuilt = TRUE)
      
    • When prompted, type 'y' for every question to proceed with the update.
  3. Verify that everything went well:
    • In R, type the following command to check the R version and the status of the packages:
    • version
      packageStatus()
      
Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

0 Response to "How to Update R on RStudio"
Next → ← Prev