Installing & Updating R and R Studio: A Visual Guide


What is the most current, stable version of R?

The current, stable release of R is R-4.2.1 as of writing this article in October 2022. The version R-4.2.1 was first released on June 23, 2022.

The majority of new features for R-4.2.1 are essentially glorified bug fixes and ease-of-use changes. It is amazing how far R has come since its 1993 August inception. Be grateful and happy that there are so many smart people working on improving and maintaining R so that people like me and you can use it.

Where can I safely download R?

You should never install R from 3rd party websites or from websites you don’t trust.

The official website to download the most updated and maintained R versions and packages is called https://cran.r-project.org. This project gives you access to a system of servers across the world maintaining these versions. In the instance when one server location might fail, there are plenty of backups in participating countries and locations.

How to install R

Windows 10

The Windows 10 installation of R has never been easier. All you do is run an executable file on your computer and, voila, you’re up and running.

Linux

Linux systems are a bit more complex than Windows or Mac. If you’re a Linux user, ideally you already know a bit about operating systems and how to use the command line interface (CLI).

  • Navigate to the Linux operating system R download page
  • Select your version of Linux. Not all versions are supported.
  • Run the installation command on your CLI that is shown on the CRAN website. For example for Fedora, the command would be:
sudo dnf install R

Mac

Installing R on the Mac operating system is about the same level of ease as using Windows. The executable files will just have a different extension name. Please note that you need to install the binary source of R, otherwise you will need to compile R using a compiler that might require an additional installation.

How to install R Studio

After you have R installed, you are going to want to install R Studio so you have a nice integrated development environment (IDE) to write code in. Traditionally, there is the basic RGui application and you could also use IDEs like Visual Studio Code or Notepad++, but these options are not as useful for R.

Let’s look at where to download and how to install R Studio for MacOS and Windows. Note that I am writing about Linux as minimally as possible as I don’t run Linux OS and the steps can be more complex than Windows or MacOS

Windows 10

  1. Navigate to https://www.rstudio.com/products/rstudio/download/
  2. Download the 64-bit Windows installer
  3. Run the executable install file (my installation file was named RStudio-2022.07.2-576.exe)
  4. Follow the user prompts to install Rstudio

Mac

  1. Navigate to https://www.rstudio.com/products/rstudio/download/
  2. Download the MacOS installer
  3. Run the executable install file (the installation file would named RStudio-2022.07.2-576.dmg as of writing this article)
  4. Follow the user prompts to install Rstudio

How to Update R

There are a few ways to update your R version. The simplest way is to download and install the latest version from https://cran.r-project.org. The downside here is that you might need to reinstall all of your packages and libraries.

Let’s look at a way to update your R version WHILE keeping your installed packages.

Windows

On Windows you can download and install the installr package and run the library’s function updateR() to upgrade your R version. The benefit of using this package is that it will try to install and update your packages with the installation of the new R version which can potentially save you alot of headache.

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

Mac

On Mac you can download and install the same installr package using devtools and run the library’s function updateR() to upgrade your R version. Updating in this way should keep your installed libraries just like the Windows version.

NOTE: I don’t run a Mac OS so I couldn’t run and verify that this code works. The source of the code is here.

install.packages('devtools') #assuming it is not already installed

library(devtools)

install_github('andreacirilloac/updateR')

library(updateR)

updateR(admin_password = 'Admin user password')

How to Update R Studio

It’s easy to update R-Studio from the R-Studio program

The easiest way to update R Studio is from the R Studio IDE application itself. Simply follow these steps:

  1. Hover over the ‘Help’ tab
  2. Select ‘Check for Updates’
  3. Follow the prompt to upgrade your version of R Studio

Additional Questions

Can you update R from the command terminal?

As far as I know, you cannot update your version of R using the command terminal with MacOS or Windows 🙁

It is possible to update your version of R from the command terminal when using the Linux OS, but not with Mac or Windows. Linux users will need to use package management to update their R version and this will be more involved than other operating systems.

Let’s look at an example of updating R from the command line interface for Linux (source).

NOTE: I am not running a Linux OS so cannot verify this code works. I would suggest refering to other information sources and consider this article a secondary source for Linux and Mac OS.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo echo "deb http://cran.wustl.edu/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt upgrade r-base r-base-dev
sudo apt update
sudo apt upgrade

Can I update R from R Studio?

Typically, you will want to update R from your IDE of choice rather than navigate to the CRAN website and install everything from scratch.

It is possible to update R from R Studio using the updateR() method in the installr package. You can install this package for Windows and Mac with minimal effort and the package will also reinstall and update your packages.

Let’s look at the commands we should run in R Studio for Windows and Mac.

Windows

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

Mac

NOTE: I don’t run a Mac OS so I couldn’t run and verify that this code works. The source of the code is here.

install.packages('devtools') #assuming it is not already installed

library(devtools)

install_github('andreacirilloac/updateR')

library(updateR)

updateR(admin_password = 'Admin user password')

Conclusion

Thanks for reading and look out for more content from RTL Coding. Hope this article was useful and if you would like to support this blog and this content feel free to donate via Paypal to help support more helpful content.

Sources

Sources

Recent Posts