How to install R and Rstudio with Homebrew on macOS. The programming language R is widely used across statisticians for data mining and data analysis. Additionally, RStudio provides an IDE for R.
Install R and RStudio with Homebrew on macOS
The R language can be downloaded from the R project website or through Homebrew. Homebrew is a package manager for macOS that allows you to easily install third-party software and keep it up-to-date. To install Homebrew, see my article on the Homebrew setup on macOS.
The R project provides official binaries for Homebrew that can be installed from the Terminal with the following command:
brew cask install r
Alternatively, the Homebrew-compiled version of R omits the GUI app and can be installed with the command:
brew install r
The R GUI is a simple editor that provides a console to run scripts written in the R language. The RStudio is a more comprehensive GUI to write scripts.
The integrated development environment (IDE) Rstudio is a wide-spread syntax-highlighting development environment for R. The Rstudio can be installed from Homebrew with the following command:
brew cask install rstudio
Using above command, Rstudio will be installed in the path
/Applications/RStudio.app. You can start RStudio either by searching it using the Spotlight search, or you navigate to the Applications folder and double-click it.
Updates to R or Rstudio can now be managed with Homebrew. The
brew update and
brew upgrade commands will retrieve and install the latest versions.