How to Install R on Mac
To install R on Mac, follow these steps:
- Open the web browser and go to www.r-project.org.
- Click the “Download R” link in the middle of the page under “Getting Started.”
- Select the nearest region’s CRAN location (a mirror site) and click the corresponding link.
- Click on the “Download R for (Mac) OS X” link at the top of the page.
- Click on the file containing the latest version of R under “Files.”
- Save the .pkg file, double-click it to open it, and follow the installation instructions.
- After installing R, you need to download and install RStudio.
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.
Here, we got some warnings that can be solved by following the below steps.
- Open Terminal
- Write or paste in:
defaults write org.R-project.R force.LANG en_US.UTF-8
- Close Terminal (including any RStudio window)
- Start R
That will resolve the issue; now our r console looks like the one below.
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:
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
- To install RStudio on Mac For Free, download it from the website first.
- Go to rstudio.com and click on the Free RStudio Desktop, free under Open Source License.
- You will go to this page.
- 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.
- Now, open the RStudio, and it looks like the below.
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.