This document explains how to install R and RStudio with Homebrew on Mac OS.
Main Instructions
The steps below will install Homebrew, R, and RStudio. Open a terminal and run the following commands.
- Install Homebrew.
usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This command will download, install, and set up Homebrew. The first time a brew
command runs it will ask for a password.
- Install R with the following commands:
brew tap homebrew/science # adds another source for applications.
brew install r # runs installer of r
The first command is necessary if you want to add science/math type applications. The second command handles all the installation of R itself. As of 3.25.2017 this installs version . This can take a while because Homebrew downloads then builds the tools though it tends to be faster an easier than manual installation.
- Install RStudio with the following command:
brew cask install rstudio
Try navigating to RStudio to verify installation.
- Optional Set up RStudio to work from the command line.
echo "alias rstudio='open -a RStudio'" >> ~/.bash_profile
source ~/.bash_profile
This sets up your bash profile to run RStudio when rstudio
is entered into the command line (i.e. rstudio example.rmd
). It adds and alias
to your ~/.bash_profile
so you can remove it if you want.
This concludes the installation of RStudio. The rest of this documentation is more on Homebrew.
Background and Info on Homebrew.
What is Homebrew.
Homebrew is a package manager for macOS (MacOS X) that claims to be The missing package manager to macOS. You can use this to find open source and UNIX tools that most Linux distros have but don’t natively show up on Mac (i.e. wget and imagemagick). It works from the command line and it makes installing, updating, and removing packages easier.
Some useful commands:
Be careful with these because they do alter/remove applications.
Update and Upgrade your packages.
$ brew update # update the formula $ brew upgrade # Upgrade outdated, unpinned brews.
List your installed packages.
$ brew list # lists all installed brews
Remove an Application
bash $ brew uninstall <formula>
For more information on Homebrew navigate to brew.sh.