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 -
- It checks for a newer version of R.
- If one exists, the function will download the most updated R version and run its installer.
- Once done, the function will offer to copy (or move) all of the packages from the old R library to the new R library.
- 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
- 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/ - Download the latest R installer.
- Run the installer, and it will guide you through the installation process.
- After updating R, open RStudio. Close RStudio if it is already opened and open it again.
- 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. - In RStudio, Go to "Tools" in the top menu and select "Global Options".
- In the "Global Options" dialog box, click on "General" on the left panel.
- Look for the "R version" section on the right panel.
- Click on the "Change" button next to "R version".
- Select the appropriate version of R
- Click "OK" to close the "R Version Chooser" dialog.
- 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.
- 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.
- 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.
- Verify that everything went well:
- In R, type the following command to check the R version and the status of the packages:
version packageStatus()
Share Share Tweet