179

I'm trying to install R using Homebrew. I ran these commands which are recommended elsewhere on SO:

brew tap homebrew/science
brew install R

For brew tap homebrew/science, I'm receiving this error:

Error: Already tapped!

For the second command, I receive this:

Error: No available formula for r 

Any suggestions?

2
  • 12
    seems that almost a year later, this is no longer a problem. The first 2 commands run with no errors. Commented Sep 9, 2014 at 20:48
  • 3
    As of 2017, brew install r will run just fine. Commented May 7, 2018 at 8:06

13 Answers 13

239

As of 2017, it's just brew install r. See @Andrew's answer below.

As of 2014 (using an Yosemite), the method is the following:

brew tap homebrew/science
brew install Caskroom/cask/xquartz
brew install r

The gcc package (will be installed automatically as a required dependency) in the homebrew/science tap already contains the latest fortran compiler (gfortran), and most of all: the whole package is precompiled so it saves you a lot of compilation time.

This answer will also work for El Capitan and Mac OS Sierra.

In case you don't have XCode Command Line Tools (CLT), run from terminal:

xcode-select --install
6
  • 3
    I also needed to install xquarts $ brew install Caskroom/cask/xquartz Commented May 14, 2015 at 10:41
  • Another intermediate step as of Jun 9, 2016: brew link fontconfig Commented Jun 9, 2016 at 17:14
  • 11
    You could also skip tapping (if you don't need anything else from homebrew/science) and run brew install homebrew/science/r
    – Alex L
    Commented Feb 9, 2017 at 7:32
  • See the answer stackoverflow.com/a/46208239/3924118, as of 2017, brew 1.3.2, using a macOS Sierra.
    – nbro
    Commented Feb 26, 2018 at 11:00
  • 4
    I got error: Error: homebrew/science was deprecated. This tap is now empty as all its formulae were migrated. Commented Jul 3, 2018 at 13:24
129

As of 2017 / Brew 1.3.2 @ macOS Sierra 10.12.6 all you have to do is:

$ brew install r

You don't even need to tap homebrew/science since r is now a part of core formulae for the Homebrew (homebrew-core).

It will also install all dependencies automatically:

==> Installing dependencies for r: gmp, mpfr, libmpc, isl, gcc

There are two additional options you might want to know:

--with-java
Build with java support
--with-openblas
Build with openblas support
3
  • 1
    @Andrew Does brew install r with "--with-java" and "--with-openblas" options?
    – chang02_23
    Commented Oct 24, 2018 at 17:26
  • @chang02_23 No, by default it is not. These options force brew to install r with dependencies (java, openblast). Default installation (brew install r) doesn't include those packages.
    – Andrew
    Commented Oct 25, 2018 at 22:08
  • 3
    For people reading this now, I tried brew install r on macOs big sur and realized later that it was doing something else when it took too long to complete. What worked for me is: brew install --cask r. Ref. formulae.brew.sh/cask/r Commented Oct 22, 2021 at 8:51
30

I used this tutorial to install R on my mac, and it had me install xquartz and a fortran complier (gfortran) as well.

My suggestion would be to brew untap homebrew/science and then brew tap homebrew/science and try again, also, make sure you don't have any errors when you run brew doctor

Hope this helps

1
  • 2
    GNU Fortran is provided as part of GCC now.
    – Liwen
    Commented Sep 11, 2014 at 12:56
23
brew install cask
brew cask install xquartz
brew tap homebrew/science
brew install r

This way, everything is packager managed, so there's no need to manually download and install anything.

0
15

Working on El Capitan 10.11.1, the steps I followed are

brew install cask    
brew tap homebrew/science    
brew install r
0
8

This is what actually worked for me on OSX Yosemite.

brew install cask
brew install Caskroom/cask/xquartz
brew install r
8

If you run

xcode-select --install

you do you not need to install gcc through brew, and you will not have to waste time compiling gcc. See https://stackoverflow.com/a/24967219/2668545 for more details.

After that, you can simply do

brew tap homebrew/science
brew install Caskroom/cask/xquartz
brew install r
3

I am working MacOS 10.10. I have updated gcc to version 4.9 to make it work.

brew update
brew install gcc
brew reinstall r
3
brew install homebrew/science/r

works on OS X 10.11.6.

3

As per the homebrew page, it is installed with the following command:

brew install --cask r
1
  • In mac Sonoma this works without issues. Commented May 7 at 12:48
2
If you meant "r" specifically:
It was migrated from homebrew/science to homebrew/core.

For r 3.4.3 Mac High Sierra:

brew tap homebrew/core
brew install Caskroom/cask/xquartz
brew install r
1

You can also install R from this page:

https://cran.r-project.org/bin/macosx/

It works out of the box

1

homebrew/science was deprecated So, you should use the following command.

brew tap brewsci/science

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.