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 😱.
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 ‘
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.
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.
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.
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.
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.
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).
Clicking this will prompt the same window as before to pop up.
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.
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).
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).
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.
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).
Select All
at the bottom to select all packages.Install Updates
.
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
.
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.
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
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”.
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
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.
After updating, open a new session of RStudio and check for updates. You should see the following window.
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
.
On the next window, under the R General
section, select the correct directory for your updated R version by clicking the Change
button.
On the next window that appears, select the updated 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”.
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.
Note: This tutorial was performed on a Windows computer.
Lead image source: stable diffusion v2.1 with prompt “Beagles playing baseball”.