How to Install R and RStudio on Mac

How to Install R on Mac

To install R on Mac, follow these steps:

  1. Open the web browser and go to www.r-project.org.
  2. Click the “Download R” link in the middle of the page under “Getting Started.”
  3. Select the nearest region’s CRAN location (a mirror site) and click the corresponding link.
  4. Click on the “Download R for (Mac) OS X” link at the top of the page.
  5. Click on the file containing the latest version of R under “Files.”
  6. Save the .pkg file, double-click it to open it, and follow the installation instructions.
  7. After installing R, you need to download and install RStudio.

Testing R

Double-click on the R icon in the Applications folder. A window titled “R Console” should pop up.

You maybe see something like the below.

Install R in Mac

Here, we got some warnings that can be solved by following the below steps.

  1. Open Terminal
  2. Write or paste in: defaults write org.R-project.R force.LANG en_US.UTF-8
  3. Close Terminal (including any RStudio window)
  4. Start R

That will resolve the issue; now our r console looks like the one below.

Solve UTF R Errors

The > character is called the prompt, where we enter the commands for the program to interpret.

For instance, if you type 11+21 followed by the return/enter key, you will see:

Testing R

That means the installation of R is successful.

To quit R, you have to. call the quit function by typing the q() in the console and hitting the return key.

How to Install RStudio on Mac

  1. To install RStudio on Mac For Free, download it from the website first.
  2. Go to rstudio.com and click on the Free RStudio Desktop, free under Open Source License. 
  3. You will go to this page.Install RStudio on macOS
  4. Then click the Download RStudio For Mac button to save the .dmg file on your machine, double-click it to open it, and then drag and drop it to your applications folder.
  5. Now, open the RStudio, and it looks like the below.

Install RStudio in Mac

To exit RStudio, click “RStudio” in the menu bar, then click “Quit RStudio”. Alternatively, use the CMD + Q shortcut.

If prompted to save the workspace, do not save it.

That’s it.

Leave a Comment