Help us understand the problem. What is going on with this article?

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

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

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

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

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

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

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

メリット

  • インストールが短時間で終わる
  • 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がインストールされていないせい。以下からバイナリを拾ってインストール。

http://xquartz.macosforge.org/landing/

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

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

http://www.rstudio.com/products/rstudio/download/

tatzyr
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした