R 4 Epidemiology - 1  Installing R and RStudio (2024)

Before we can do any programming with R, we first have to download it to our computer. Fortunately, R is free, easy to install, and runs on all major operating systems (i.e., Mac and Windows). However, R is even easier to use as when we combine it with another program called RStudio. Fortunately, RStudio is also free and will also run on all major operating systems.

At this point, you may be wondering what R is, what RStudio is, and how they are related. We will answer those questions in the near future. However, in the interest of keeping things brief and simple, We’re not going to get into them right now. Instead, all you have to worry about is getting the R programming language and the RStudio IDE (IDE is short for integrated development environment) downloaded and installed on your computer. The steps involved are slightly different depending on whether you are using a Mac or a PC (i.e., Windows). Therefore, please feel free to use the table of contents on the right-hand side of the screen to navigate directly to the instructions that you need for your computer.

Note

In this chapter, we cover how to download and install R and RStudio on both Mac and PC. However, the screenshots in all following chapters will be from a Mac. The good news is that RStudio operates almost identically on Mac and PC.

Step 1: Regardless of which operating system you are using, please make sure your computer is on, properly functioning, connected to the internet, and has enough space on your hard drive to save R and RStudio.

1.1 Download and install on a Mac

Step 2: Navigate to the Comprehensive R Archive Network (CRAN), which is located at https://cran.r-project.org/.

R 4 Epidemiology - 1 Installing R and RStudio (1)

Step 3: Click on Download R for macOS.

R 4 Epidemiology - 1 Installing R and RStudio (2)

Step 4: Click on the link for the latest version of R. As you are reading this, the newest version may be different than the version you see in this picture, but the location of the newest version should be roughly in the same place – the middle of the screen under “Latest release:”. After clicking the link, R should start to download to your computer automatically.

R 4 Epidemiology - 1 Installing R and RStudio (3)

Step 5: Locate the package file you just downloaded and double click it. Unless you’ve changed your download settings, this file will probably be in your “downloads” folder. That is the default location for most web browsers. After you locate the file, just double click it.

R 4 Epidemiology - 1 Installing R and RStudio (4)

Step 6: A dialogue box will open and ask you to make some decisions about how and where you want to install R on your computer. We typically just click “continue” at every step without changing any of the default options.

If R installed properly, you should now see it in your applications folder.

R 4 Epidemiology - 1 Installing R and RStudio (6)

Step 7: Now, we need to install the RStudio IDE. To do this, navigate to the RStudio desktop download website, which is located at https://posit.co/download/rstudio-desktop/. On that page, click the button to download the latest version of RStudio for your computer. Note that the website may look different that what you see in the screenshot below because websites change over time.

R 4 Epidemiology - 1 Installing R and RStudio (7)

Step 8: Again, locate the DMG file you just downloaded and double click it. Unless you’ve changed your download settings, this file should be in the same location as the R package file you already downloaded.

R 4 Epidemiology - 1 Installing R and RStudio (8)

Step 9: A new finder window should automatically pop up that looks like the one you see below. Click on the RStudio icon and drag it into the Applications folder.

R 4 Epidemiology - 1 Installing R and RStudio (9)

You should now see RStudio in your Applications folder. Double click the icon to open RStudio.

R 4 Epidemiology - 1 Installing R and RStudio (10)

If this warning pops up, just click Open.

R 4 Epidemiology - 1 Installing R and RStudio (11)

The RStudio IDE should open and look something like the window you see here. If so, you are good to go! 🎉

R 4 Epidemiology - 1 Installing R and RStudio (12)

1.2 Download and install on a PC

Step 2: Navigate to the Comprehensive R Archive Network (CRAN), which is located at https://cran.r-project.org/.

R 4 Epidemiology - 1 Installing R and RStudio (13)

Step 3: Click on Download R for Windows.

R 4 Epidemiology - 1 Installing R and RStudio (14)

Step 4: Click on the base link.

R 4 Epidemiology - 1 Installing R and RStudio (15)

Step 5: Click on the link for the latest version of R. As you are reading this, the newest version may be different than the version you see in this picture, but the location of the newest version should be roughly the same. After clicking, R should start to download to your computer.

R 4 Epidemiology - 1 Installing R and RStudio (16)

Step 6: Locate the installation file you just downloaded and double click it. Unless you’ve changed your download settings, this file will probably be in your downloads folder. That is the default location for most web browsers.

R 4 Epidemiology - 1 Installing R and RStudio (17)

Step 7: A dialogue box will open that asks you to make some decisions about how and where you want to install R on your computer. We typically just click “Next” at every step without changing any of the default options.

R 4 Epidemiology - 1 Installing R and RStudio (18)

If R installed properly, you should now see it in the Windows start menu.

R 4 Epidemiology - 1 Installing R and RStudio (19)

Step 8: Now, we need to install the RStudio IDE. To do this, navigate to the RStudio desktop download website, which is located at https://posit.co/download/rstudio-desktop/. On that page, click the button to download the latest version of RStudio for your computer. Note that the website may look different that what you see in the screenshot below because websites change over time.

R 4 Epidemiology - 1 Installing R and RStudio (20)

Step 9: Again, locate the installation file you just downloaded and double click it. Unless you’ve changed your download settings, this file should be in the same location as the R installation file you already downloaded.

R 4 Epidemiology - 1 Installing R and RStudio (21)

Step 10: Another dialogue box will open and ask you to make some decisions about how and where you want to install RStudio on your computer. We typically just click “Next” at every step without changing any of the default options.

R 4 Epidemiology - 1 Installing R and RStudio (22)

When RStudio is finished installing, you should see RStudio in the Windows start menu. Click the icon to open RStudio.

R 4 Epidemiology - 1 Installing R and RStudio (23)

The RStudio IDE should open and look something like the window you see here. If so, you are good to go! 🎉

R 4 Epidemiology - 1 Installing R and RStudio (24)

R 4 Epidemiology - 1  Installing R and RStudio (2024)

References

Top Articles
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 6041

Rating: 4.6 / 5 (46 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.