R: Installing R on a Mac using Homebrew
How to install R environment for statistical computing using Homebrew.
Step 1 - XCode Command line
If you're on a Mac, you will need to first install XCode command-line tools.
Step 2 - Install Homebrew
Homebrew is a package manager for Mac and if you haven't installed it yet, follow this tutorial.
Step 3 - Install xQuartz
2.x.x+ no longer requires you to manually install
brew cask install xquartz
Step 4 - Install R
Finally, we can install R!
brew install r
Step 5 - TK Graphic Library
Install the TK Graphical Library.
brew cask install tcl
Step 6 - Double Check Your Work
Run doctor to ensure your system is healthy.
Cleanup any files.
Step 7 - Run R
If everything is working properly, you should be able to run
R (notice that it's capital) and the
TK GUI. This GUI is what you will be using to visualize your statistical questions.
R -g Tk &
Step 8 - Run Rscript
Suppose you have an external file named 'myfirstfile.R' and you want to run it from the command line, here's how:
If you're not sure where to go next, I suggest learning how to install a very popular graphics package called
ggplot2. Read my tutorial to learn more.
If homebrew ends up changing stuff and you can no longer find the right package, try
brew search <name of package>