LoginSignup
53
45

More than 3 years have passed since last update.

OS XにRをインストールする2種類の方法の検討

Last updated at Posted at 2015-03-29

macOSにRをインストールする方法は主に2つある。

  1. Rの公式サイトにあるバイナリを使う
  2. Homebrewでインストールする

それぞれにメリットとデメリットがある。

方法1: 公式サイトのバイナリを使う

公式サイトにあるR-3.x.x.pkgをダウンロードしてインストールする。

メリット

  • インストールが短時間で終わる
  • gccをインストールしなくてもよい

デメリット

  • /usr/local/以下にいろいろ書き込むので$ brew doctorしたときにWarningが出るようになる

Warningについて

バージョン3.2.2をインストールしたあとに$ brew doctorした時のWarningは以下の通り。無視してもあまり問題はない。

$ brew doctor
Warning: Some directories in /usr/local/share/man aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
directories, then the install will fail during the link step.
You should probably `chown` them:

    /usr/local/share/man/mann
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libtcl8.6.dylib
    /usr/local/lib/libtk8.6.dylib
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/fakemysql.h
    /usr/local/include/fakepq.h
    /usr/local/include/fakesql.h
    /usr/local/include/itcl.h
    /usr/local/include/itcl2TclOO.h
    /usr/local/include/itclDecls.h
    /usr/local/include/itclInt.h
    /usr/local/include/itclIntDecls.h
    /usr/local/include/itclMigrate2TclCore.h
    /usr/local/include/itclTclIntStubsFcn.h
    /usr/local/include/mysqlStubs.h
    /usr/local/include/odbcStubs.h
    /usr/local/include/pqStubs.h
    /usr/local/include/tcl.h
    /usr/local/include/tclDecls.h
    /usr/local/include/tclOO.h
    /usr/local/include/tclOODecls.h
    /usr/local/include/tclPlatDecls.h
    /usr/local/include/tclThread.h
    /usr/local/include/tclTomMath.h
    /usr/local/include/tclTomMathDecls.h
    /usr/local/include/tdbc.h
    /usr/local/include/tdbcDecls.h
    /usr/local/include/tdbcInt.h
    /usr/local/include/tk.h
    /usr/local/include/tkDecls.h
    /usr/local/include/tkPlatDecls.h
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
    /usr/local/lib/pkgconfig/tcl.pc
    /usr/local/lib/pkgconfig/tk.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
    /usr/local/lib/libtclstub8.6.a
    /usr/local/lib/libtkstub8.6.a

方法2:Homebrewでインストールする

以下のコマンドでインストールする。

$ brew tap homebrew/science
$ brew install R

OpenBLASを使う場合は、

$ brew tap homebrew/science
$ brew install openblas --build-from-source
$ brew install R --with-openblas

メリット

  • $ brew doctorしたときにWarningが出ない
  • 自分でビルドしたOpenBLASを使える

デメリット

  • インストールに時間がかかる
  • gccを入れる必要がある

なぜgccがデメリットなのか

HomebrewにあるRはgccに依存している。Fortranを使う関係で、macOSに標準で入っているclangではダメっぽい。

gccのインストール/アップデートにはありえないくらい時間がかかる。しかも、gccは結構頻繁にアップデートされるので、$ brew upgradeを気軽に実行できなくなってしまう。

おまけ:Rが起動しない?

だいたいXQuartzがインストールされていないせい。以下からバイナリを拾ってインストール。

おまけ:RStudioのインストール

公式サイトのMac用バイナリをダウンロード。dmgを開いてRStudio.appを/Applications/にコピー。

53
45
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
53
45