paint-brush
Be a Shortstop Beagle: Learn How to Update R and RStudio to the Latest Versionby@jessblaq
37,329 reads
37,329 reads

Be a Shortstop Beagle: Learn How to Update R and RStudio to the Latest Version

by Jessica BlaquiereApril 4th, 2023
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

R is the open-source programming language itself, and RStudio is the integrated development environment (IDE) That allows users to code with R and have easy access to tools, data, and visualizations. Learn to update R, RStudio, and packages.
featured image - Be a Shortstop Beagle: Learn How to Update R and RStudio to the Latest Version
Jessica Blaquiere HackerNoon profile picture


You’re been working on a project in RStudio for days and are knee-deep in code and loaded libraries. Things are going great…until they aren’t anymore 🙄. Suddenly, the dreaded error messages pop up when you try to utilize a library you’ve been using effortlessly so far. You decide to ignore it for now and worry about it later. But the next time you open your RStudio session, another problem arises. It’s time to update your RStudio software. You reason with yourself and decide to take care of it now because you know all too well, these issues and indicators ONLY KEEP COMING 😱.



Source: Giphy


These problems can be scary and intimidating when you’re in the middle of a workflow, even for the most experienced programmers. For one, you have to disrupt the ‘flow state’ that you have magically achieved. No one wants to stop what they’re doing so they can jump into troubleshooting mode.


Second, programming can be finicky and there are many moving pieces. Once you’ve found a working method, you just don’t want to mess with it. Updating your software leads to updating your libraries and it’s impossible to know if those updates may lead to bugs in your code.


Source: Giphy


Table of Contents:

  1. What is R and RStudio?
  2. Why you should keep your software updated.
  3. How to check your current version of R and RStudio.
  4. Sidetrack - Updating R packages.
  5. How to update R.
  6. How to update RStudio.
  7. Troubleshooting.

R and RStudio - What’s the Difference?

R is the open-source programming language itself, and RStudio is the integrated development environment (IDE) that allows users to code with R and have easy access to tools, data, and visualizations in a tidy console-like environment. Unfortunately, you have to update them independently. Although, you can get away with only updating RStudio most of the time and leaving R alone.



Why You Should Stay up to Date

A common reaction to this scenario is to put off the updates and “think about it later”. That might work for a little while, but here’s why you should just deal with it right away and keep your software updated.


  1. Benefit from the latest new features of RStudio.
  2. Repair issues that you’re having.
  3. Remedy underlying bugs that RStudio programmers have updated, even if they haven’t affected your workflow (yet).
  4. Eliminate those pesky warning messages.
  5. Maintain R and RStudio in a happy state of being together.

How To Check Your Current Version of R and RStudio

There are a few methods to check your current software version(s). It’s good to take note of the version(s) you are using now, just in case you run into any issues and decide you want to revert backward. This is unlikely, but you might as well be cautious.


RStudio - Method 1:

Mostly, you’ll see a pop-up window like the one below when you open RStudio. This tells you your current version and which version is available.


RStudio - Update Available window.


RStudio - Method 2:

If you’re not receiving these update indications, you can still check for updates manually. First, you navigate to the Help tab and select Check for Updates (highlighted in yellow below).



RStudio - Help tab - Check for Updates.



Clicking this will prompt the same window as before to pop up.



RStudio - Update Available window.


R - Method 1:

To check your current version of R, type sessionInfo() into the console (seen in blue font below). Running the command will yield the following results. The results show that R version 4.2.1 is currently in use.


RStudio Console contents after 'sessionInfo()' prompt.


R - Method 2:

Things are getting redundant now, but the easiest method to check your version of R (and the funniest) is to simply open RStudio, look to the console, and read the text displayed.You’ll notice the project team that developed this version gave it a humorous name. In this case, R version 4.2.1 is also known as “Funny-Looking-Kid” 😭 (highlighted in yellow below).



RStudio Console contents upon loading a new session.


A Sidetrack

You might not be ready to update RStudio altogether, but you’re receiving error messages and bugs related to packages. Keep in mind you can try updating the troublesome package and see if that remedies the error. Navigate to your Packages tab where you can see a list of RStudio packages. Click the Update button (see image below).


RStudio - Packages tab.



After clicking Update on the Packages tab, a new window will appear like the image shown below. The new window informs you of the package version you have installed currently and which version is available to be installed.



RStudio - Update Packages window.



You can also click on the NEWS button for the package of interest to see what has been updated. Clicking this button will open a browser with a list of information. For example, clicking ggplot2’s NEWS button reveals numerous changes and bug fixes in the new version (see the image below).



RStudio - NEWS related to gglot2 version 3.4.


Updating Packages:

Method 1: Update Every Package

  • Click Select All at the bottom to select all packages.
  • Click Install Updates.


Method 2: Update Only Select Packages

  • Click the box next to the package(s) you wish to update.

  • Select Install Updates.

  • A warning prompt requesting to restart R will appear, click Yes.



RStudio - Update Packages window with 2 selected packages.



RStudio warning window to restart R.



After the update is complete, you will notice the changes listed in the console. Your package version should be updated within the list of packages.



How to Update R

If you’re planning on updating both R and RStudio, it’s more logical to update R first but you can update them in either order. If you’re only planning on updating RStudio, proceed to the next section.


Navigate to r-project and look up the latest version of R. To download the latest version, you’ll have to choose your CRAN mirror which is sorted regionally. CRAN is a network of servers that store the latest versions of R. They ask to choose the mirror “nearest to you to minimize network load”. Download and install the file.



R - download link for verson 4.2.3



Confirm that you have successfully installed the latest version and move on to updating RStudio. The image below shows that R has been updated to version 4.2.3 “Shortstop Beagle”.



R Console version informaton


How to Update RStudio

Now you know what version you are running, what next?


From the updater popup window, click on Quit and Download. This action will close your RStudio session and RStudio Desktop - Posit will open automatically in your browser.


RStudio downloader



Download the latest version, open the installation file, and you will be greeted with the RStudio Setup window. Next, you can select your Start Menu Folder, and which version of R you would like to use. If you have installed the latest R, select the specific version.



RStudio Start Menu Folder


RStudio setup - choose version of R



After updating, open a new session of RStudio and check for updates. You should see the following window.


RStudio has been updated!


Troubleshooting

Both R and RStudio should be updated now. But your console session in RStudio reads that you are still using the old version of R. What gives? You may have to do one last step to select the updated version of R.


In RStudio, under the Tools tab, select Global Options.

RStudio Tools Tab - Global Options



On the next window, under the R General section, select the correct directory for your updated R version by clicking the Change button.



RStudio Options Window - Select R Version


On the next window that appears, select the updated version of R.


RStudio window - select specific version of R



Finally, close your RStudio session, reopen it, and inspect the console. It should read the latest version of R installed. In my case, I am now using R 4.2.3 or “Shortstop Beagle”.



RStudio console message - R version 4.2.3 "Shortstop Beagle"



Final Thoughts

Now you have learned how to update R, RStudio, and your packages. Things should be smooth sailing now and you can get back into working in the zone.


Source: Giphy



Note: This tutorial was performed on a Windows computer.

Lead image source: stable diffusion v2.1 with prompt “Beagles playing baseball”.