What R is and why you might need it

R is a free programming language built for statistical analysis and data visualization. If you work with spreadsheets, databases, or datasets that need graphing or statistical testing, R lets you automate those tasks instead of doing them by hand in Excel. It runs on Windows, Mac, and Linux.

R is different from most software you install — it's a command-line tool, meaning you type instructions rather than clicking buttons. Most people use R through a separate program called RStudio, which gives you a friendlier interface. This guide covers installing both R itself and RStudio, which is the setup most beginners use.

You do not need programming experience to start. R has a learning curve, but the installation itself is straightforward, and thousands of free tutorials exist for the specific tasks you want to do.

Key Takeaways

  • R is the underlying language, and RStudio is the program most people use to write and run R code — you need both.
  • Download R first from cran.r-project.org, then download RStudio from posit.co, because RStudio requires R to be installed already.
  • The installation process is the same as installing any other Windows or Mac program — download, open the installer, and follow the prompts.
  • After installation, open RStudio (not R itself), and you will see a console where you can start typing commands.

Installing R on Windows

Go to cran.r-project.org in your web browser. On the left side of the page, you will see a section labeled "Download and Install R". Click the link that says "Download R for Windows".

On the next page, click "base" near the top. This gives you the standard version of R. Then click the large blue button labeled "Download R X.X.X for Windows" (the X's will be version numbers). The file will download to your Downloads folder.

Open your Downloads folder, find the file you just downloaded (it will be named something like "R-4.3.2-win.exe"), and double-click it. A setup wizard will open. Click "Next" through each screen, accepting the default settings. When you reach the screen asking where to install R, the default location (usually C:\Program Files\R) is fine. Click "Finish" when the installation completes.

R is now installed, but you will not use it directly. Move on to installing RStudio instead.

Installing R on Mac

Go to cran.r-project.org in your web browser. Click "Download R for macOS" on the left side.

On the next page, look for the section labeled "Latest release". If you have an Apple Silicon Mac (M1, M2, M3 chip), download the file labeled "R-X.X.X-arm64.dmg". If you have an older Intel-based Mac, download "R-X.X.X-x86_64.dmg". If you are not sure which you have, click the Apple menu in the top-left corner, select "About This Mac", and look at the "Chip" line.

Once the file downloads, open your Downloads folder and double-click the .dmg file. A window will open showing an R icon and an Applications folder. Drag the R icon into the Applications folder. This copies R to your computer. When the copy finishes, you can close the window and eject the disk image.

R is now installed. Next, install RStudio.

Installing RStudio on Windows and Mac

Go to posit.co/download/rstudio-desktop in your web browser. The page will detect your operating system automatically. Click the blue button labeled "Download RStudio for [your system]".

The file will download to your Downloads folder. Open Downloads, find the RStudio installer file, and double-click it. On Windows, the file will be named something like "RStudio-2023.12.0-369.exe". On Mac, it will be "RStudio-2023.12.0-369.dmg".

On Windows, a setup wizard will appear. Click "Next" through each screen and accept the default settings. Click "Finish" when done. On Mac, a window will open showing an RStudio icon and an Applications folder. Drag the RStudio icon into Applications, then close the window.

RStudio is now installed. You can delete the installer files from your Downloads folder if you want to free up space.

Opening RStudio and checking your installation

Open RStudio by searching for it in your Start menu (Windows) or Applications folder (Mac). The program will launch and show you four panels: a large console panel on the left, an environment panel in the top-right, a files panel in the bottom-right, and a source editor panel that will appear when you create a new file.

In the console panel on the left, you should see text that says "R version X.X.X" followed by some information about R. This confirms that R is running correctly inside RStudio. Below that, you will see a > symbol (called the prompt). This is where you type commands.

Type the following and press Enter: 2 + 2. RStudio should print [1] 4 on the next line. If it does, your installation is working. If you see an error message, restart your computer and try opening RStudio again.

Installing packages (optional but common)

R comes with basic functions built in, but most data work requires packages — add-ons that other people have written and shared for free. The most popular package for data work is called tidyverse, which makes organizing and visualizing data much easier.

To install a package, type this in the console and press Enter: install.packages("tidyverse"). RStudio will download and install the package. This may take a minute or two. You will see text scrolling in the console as it works. When it finishes, you will see the prompt > again.

You only need to install a package once. After that, you load it at the start of each session by typing library(tidyverse) in the console. Do not install packages every time you use them — install once, load every time.

Troubleshooting common installation problems

If RStudio will not open, the most common cause is that R itself did not install correctly. Go back to cran.r-project.org, download R again, and run the installer a second time. Sometimes the first attempt fails silently. After reinstalling R, try opening RStudio again.

If you see an error message saying "R is not installed" or "Cannot find R", your computer cannot locate the R installation. On Windows, check that R is in C:\Program Files\R. On Mac, check that R is in your Applications folder. If it is not there, download and install R again from cran.r-project.org.

If RStudio opens but the console shows an error, close RStudio completely, restart your computer, and open RStudio again. Most console errors clear up after a restart.

If you are still stuck, the RStudio support page at support.posit.co has guides for specific error messages. You can also search for your exact error message on Stack Overflow, where thousands of R users answer questions.

Frequently Asked Questions

Do I need to install R if I already have RStudio?

Yes. RStudio is only an interface — it needs R installed underneath to actually run. If you try to open RStudio without R, it will not work. Always install R first, then RStudio.

Can I use R without RStudio?

Yes, but most beginners should not. R has a basic command-line interface that works, but RStudio is much easier to learn in because it shows your code, results, and files all in one organized window. RStudio is free and worth the extra step.

What is the difference between R and RStudio?

R is the programming language itself — the engine that does the math and analysis. RStudio is a separate program that makes writing and running R code easier. Think of R as the engine and RStudio as the dashboard.

How much disk space does R need?

R itself takes about 100 to 200 megabytes. RStudio takes about 300 to 400 megabytes. Packages you install later add more space, but most people use less than 2 gigabytes total even after installing many packages. This is tiny by modern standards.

Is R safe to install on my work computer?

R is open-source and widely used in universities and companies. It is safe. However, check your workplace's policy first — some organizations require approval before installing new software. If your company has an IT department, ask them before installing anything.