You are currently viewing Install R & RStudio on Mac OS

R Programming language comes with a Mac Installer package to install it on Mac (macOS) and it also comes with an RStudio IDE to run R programs. The RStudio IDE is a collection of integrated tools that helps you to write R programs and tests. It includes a console, syntax-highlighting editor that supports direct code execution, and a variety of robust tools for plotting, viewing history, debugging, and managing your workspace.

Advertisements

1. Download R Package for Mac (macOS)

Let’s start by downloading the R package for Mac (macOS) from the following URL. You can also find the R installer for Windows, Linux, and other platforms.

http://lib.stat.cmu.edu/R/CRAN/

Click Download R for macOS and select the version you’d like to use for running R programs. This will download the r*.pkg file to your computer.

2. Install R Package on Mac (macOS)

After the download finishes, locate the downloaded folder and install the R package on it. You should see something like this below.

Follow the instructions on the screen and complete the installation of the R package with the default settings. Once complete you should get the following screen

3. Install XQuartz (Optional)

If it is needed for you, install XQuartz by downloading from the same link you used to download the R language.

4. Download and Install RStudio IDE on Mac (macOS)

To download the rstudio IDE, go to the following link:

https://www.rstudio.com/products/rstudio/download/.

Scroll down and select the free version. You’ll be taken to a page with the available RStudio versions for download. Choose the one that matches your version of macOS. Once the download is complete, open the file to begin the installation process. Follow the on-screen instructions to install the software.

This completes the installation of R and RStudio from Mac (macOS)

5. Open RStudio


Launch the RStudio application from the dock or through your list of applications, and you should see a screen similar to the one below. This screen will show RStudio with a command prompt where you can execute any R programming language statements.

install rstudio for r

Now let’s run the hello world program in R, here I will just enter print('Hello World') at the prompt and press enter to execute the R snippet. Once you successfully run this and you can explore either the R language statements or jump to R Vector, R Matrix, and R Data Frames.


# Print Hello World
> print('Hello World')
[1] "Hello World"
> 

If you wanted to use third-party packages like dplyr you need to install the package first.

6. Conclusion

I hope you are able to successfully download and install the R language/package and RStudio on Mac (macOS) to run the R programs. RStudio is an editor to write and executing R programs.