Chapter 5 R/RStudio Installation

In this chapter we will walk you through how to install R and RStudio on your computer, and how to troubleshoot common problems before starting to learn the material!

5.1 Installing R

Note: If you already have a version of R installed on your computer, see Updating R/RStudio section

R is a programming language. It is widely used by researchers to complete tasks for their analyses, because it is accessible and handles large datasets efficiently. It is also free!

There are other software and programming tools that can be used for data wrangling and analysis, however R/RStudio is the most commonly used tool within research fields. Because of this, there is quite a bit of community support platforms and resources available to help you.

It is important to remember what you learned in the previous chapter about operating systems. Each operating system is not the same, which is why they require different steps to download and install R.

5.1.1 Windows

To install R for the first time on Windows OS, follow these steps!

  1. Go to the CRAN Website
  2. Select “Download R for Windows”
  3. Click “Install R for the first time”

This will prompt an .exc file to be downloaded into the Downloads folder on your computer. This file executes the installation! If this is not the case, you should see a downloads icon in the toolbar of your internet browser. Select this to find where the .exc file.

  1. Once the file is downloaded, double click it to open, and start the installation process.
  2. Allow the app to make changes to your device, and select your installation language!
  3. follow the Set-Up wizard instructions, select finish and then BOOM! R is installed!

Remember: you aren’t finished just yet! Although you can use R, we want to install the RStudio Interface first!

5.1.2 Mac

To install R for the first time on MacOS, follow these steps!

  1. Go to the CRAN Website
  2. Select “Download R for macOS”
  3. Select the most recent .pkg file to download the most recent version of R.

If you have an older Mac computer, sometimes the newest version of R cannot be installed. If that is the case, below the most recent version there will be a version for older macs. That version of Mac, or older, must install the second version of R.

Once a .pkg file is selected, it will prompt the file to be downloaded in the Downloads folder on your computer. Most Mac computers can access their Downloads folder from the toolbar at the bottom of their screen.

  1. Once the file is downloaded, double click it to open, and follow the installation directions.

Remember: you aren’t finished just yet! Although you can use R, we want to install the RStudio Interface first!

5.2 Installing RStudio

In the previous section you learned how to install R on your computer. You may see a a new desktop shortcut that looks like a blue R. If you double-click this shortcut, it will open the R Gui. Although technically you can use this to conduct tasks with R, we will be installing and using RStudio.

RStudio is a free integrated development environment (IDE), meaning it acts as your work space or interface when using R. You cannot use RStudio without previously installing R.

To install RStudio for the first time, follow these steps:

  1. Go to the posit website by clicking this link
  2. Once the link has loaded, check the operating system listed under the install RStudio

If the blue Download button contains the same operating system as your computer, click the button. If not, scroll down to the list of Download versions and select the version that matches the operating system you have!

INCLUDE A PICTURE OF THAT HERE.

  1. Clicking a download option will prompt your computer to download the installation file. Once completed, click the file to open it.
  2. Follow the installation directions provided to finish the installation process.

Once RStudio is installed on your computer, you may not see a shortcut on your Desktop. If this is not the case, open Task Manager or Finder and search for RStudio. When you find it, open it.

You will see the RStudio icon on you Toolbar or Dock, right-click the icon and select the option that will pin it. Now when you exit RStudio, you will always be able to open it by looking at the bottom of your screen.

Remember: We will always be using RStudio when we are using R!

5.3 Installing R Tools

Currently, only Windows users can install RTools. RTools is used to create and build R packages, and install packages from source. This means that if a package is not included on the CRAN binary list, you cannot install it without using RTools.

This is relevant when you are conducting more specific analysis and are using a more niche package, often from Github.

To install RTools, click here.

You then must select the the RTools version that corresponds with the version of R that you currently are using. You can find this by opening RStudio and looking at the bottom left pane.

Follow the installation steps like you would have done when installing R and RStudio, don’t be alarmed if it takes a long time!

NOT SURE IF MAC HAS THEIR OWN TOOLS THEY NEED

5.4 Updating

In a perfect world, you would have to install these tools once. Sadly this is not the case, there are constantly updates and changes made to the packages used in R, R, and RStudio.

This causes issues for people because often times a package is changed when it is updated, which can affect whether your code will work. If you don’t have the latest versions of R and RStudio, you may lose access to packages because they were built for a newer version.

to avoid this issue we will show you how to update R and RStudio.

5.4.1 Updating RStudio

Often times RStudio will prompt you when there is a new update available. When this occurs, click the link to download and install the newest version.

NEED TO GO THROUGH THESE STEPS MORE

5.4.2 Updating R

GO THROUGH HOW TO UPDATE R IN RSTUDIO USING THE INSTALLR PACKAGE

5.5 Chapter Wrap-Up

After reading this chapter you should have learned how to properly install R and Rstudio on your computer, update the software when needed, and troubleshoot common problems.

5.5.1 Chapter Terms & Definitions

Here is a summary of some of the bolded terms used throughout this chapter, refer back to this list whenever you need a refresher!

CRAN - The Comprehensive R Archive Network, used globally to store up-to-date code and documentation for R.