The fastest way to get R running on your computer
R is a free programming language built for statistics and data analysis. To use it, you download an installer from the official R project, run it on your computer, and then choose an editor to write code in. The whole process takes about ten minutes.
Where you download R depends on your operating system. Windows and Mac users get installers from CRAN (the Comprehensive R Archive Network). Linux users typically install R through their system's package manager. After installation, most people use RStudio — a separate program that makes writing R code much easier — though it is optional.
Key Takeaways
- Download R from cran.r-project.org, choosing the version for Windows, Mac, or Linux.
- Run the installer and accept the default settings unless you have a specific reason to change them.
- After R is installed, download and install RStudio from rstudio.com to get a user-friendly editor for writing code.
- Test your installation by opening R or RStudio and typing a simple command like 2 + 2 to confirm it works.
Installing R on Windows
Go to cran.r-project.org and click "Download R for Windows" on the left side. Then click "base" to get the main R installer. Click the download link at the top of the page — it will be labeled something like "Download R 4.x.x for Windows" with the current version number.
Once the .exe file downloads, double-click it to open the installer. Choose your language, then click Next through each screen. The default settings work for almost everyone — the installer will put R in Program Files and set up the necessary shortcuts. Click Finish when done.
R is now installed. You can open it by searching for "R" in the Windows Start menu, but most people install RStudio instead and use that to run R code.
Installing R on Mac
Go to cran.r-project.org and click "Download R for macOS" on the left side. Look for the installer labeled "R-4.x.x.pkg" (with the current version number) and download it. If you have an Apple Silicon Mac (M1, M2, or newer), download the "arm64" version. If you have an older Intel Mac, download the "x86_64" version.
Double-click the .pkg file to open the installer. Follow the prompts, accept the license agreement, and choose where to install R — the default location works fine. Enter your Mac password when prompted and click Install.
After installation finishes, R is ready to use. Like Windows users, Mac users typically open RStudio to write and run code rather than using R directly.
Installing R on Linux
Linux installation depends on your distribution. For Ubuntu or Debian-based systems, open a terminal and run these commands in order:
- sudo apt update
- sudo apt install r-base
For Fedora, CentOS, or RHEL-based systems, use:
- sudo dnf install R
For Arch Linux, use:
- sudo pacman -S r
After the installation finishes, type R in your terminal to start R and confirm it works. Type q() to exit.
Installing RStudio after R is set up
RStudio is a separate program that gives you a cleaner interface for writing R code. It is optional — R works without it — but most beginners find it much easier to use. Go to rstudio.com/download and scroll down to "RStudio Desktop" (the free version). Click the download button for your operating system.
On Windows and Mac, run the installer the same way you ran the R installer — double-click the file and follow the prompts. On Linux, follow the instructions on the download page for your distribution, which usually means running a command in the terminal.
Once RStudio is installed, open it. You should see a window with multiple panels. RStudio has found your R installation automatically. You are ready to start writing code.
Testing your installation
Open R or RStudio. In the console (the panel where you can type commands), type 2 + 2 and press Enter. If you see [1] 4 as the result, your installation is working.
Try one more command to be sure: type Sys.Date() and press Enter. You should see today's date. If both commands work, R is installed and ready to use.
Updating R later
R releases new versions periodically. To update, download and run the installer again from cran.r-project.org using the same steps above. Your old version will be replaced. Any packages you installed will still be there, though you may need to reinstall them if they are not compatible with the new version.
RStudio updates itself automatically in most cases, but you can also check for updates manually by going to Help > Check for Updates in the RStudio menu.
Frequently Asked Questions
Do I have to install RStudio, or can I just use R?
You can use R without RStudio. R includes a basic console where you can type commands. RStudio is a separate program that makes the experience more user-friendly with better organization, syntax highlighting, and built-in tools. Most people find RStudio worth installing, but it is not required.
What if the installer says I need administrator permission?
You need administrator rights on your computer to install R. If you are on a work or school computer, contact your IT department to install it for you, or ask if R is already available on a shared server you can use remotely.
How much disk space does R need?
R itself takes about 100 to 200 megabytes of disk space. RStudio takes another 300 to 500 megabytes. Packages you install later will add more space, but you will have plenty of room on any modern computer.
Can I have multiple versions of R installed at the same time?
Yes, but it is not common. Most people uninstall the old version before installing a new one to avoid confusion. If you do keep multiple versions, RStudio will use whichever one you set as the default in its settings.
What should I do if the installation fails?
Restart your computer and try again. If it fails a second time, check that you downloaded the correct version for your operating system and that your internet connection did not drop during the download. You can also visit the R project's FAQ page at cran.r-project.org/faqs.html for troubleshooting steps specific to your system.