R Open 3.5(Ubuntu版)をLubuntu16にインストールした時のメモです。
ダウンロード
-
googleで「R Open」を検索し Revolution R Open - MRAN - Microsoft ( https://mran.microsoft.com/open ) のページを開きます。開くことができたら右端の「DOWNLOAD」ボタンをクリックします。
-
左側の一覧からUbuntuのところの「Download」ボタンをクリックするとダウンロードが始まります。2018/12/29の時点ではバージョンは3.5.1でUbuntuの14.04と16.04が対応となっていました。
インストール
ダウンロードした microsoft-r-open-3.5.1.tar.gz を解凍してインストールします。何のトラブルもなくすんなりとインストールできました。
tar xvfz microsoft-r-open-3.5.1.tar.gz
cd microsoft-r-open
sudo ./install.sh
$ tar xvfz microsoft-r-open-3.5.1.tar.gz
microsoft-r-open/
microsoft-r-open/deb/
microsoft-r-open/deb/microsoft-r-open-foreachiterators-3.5.1.deb
microsoft-r-open/deb/microsoft-r-open-mkl-3.5.1.deb
microsoft-r-open/deb/microsoft-r-open-mro-3.5.1.deb
microsoft-r-open/install.sh
microsoft-r-open/MKL_EULA.txt
microsoft-r-open/MRO_EULA.txt
microsoft-r-open/rpm/
microsoft-r-open/rpm/microsoft-r-open-foreachiterators-3.5.1.rpm
microsoft-r-open/rpm/microsoft-r-open-mkl-3.5.1.rpm
microsoft-r-open/rpm/microsoft-r-open-mro-3.5.1.rpm
$ cd microsoft-r-open
/microsoft-r-open$ sudo ./install.sh
Press [Enter] key to display the Microsoft R Open license. When finished reading, press q to continue: q
Do you wish to install the Intel MKL libraries?
Choose [y]es|[n]o y
Press [Enter] key to display the Intel MKL license. When finished reading, press q to continue:
Do you agree to the terms of the previously displayed license?
Choose [y]es|[n]o y
Updating apt package repositories...done
Installing apt package dependencies libxt6 libsm6 libpango1.0-0 libgomp1 curl less...done
Installing /microsoft-r-open/deb/microsoft-r-open-mro-3.5.1.deb...done
Installing /microsoft-r-open/deb/microsoft-r-open-foreachiterators-3.5.1.deb...done
Installing /microsoft-r-open/deb/microsoft-r-open-mkl-3.5.1.deb...done
Thank you for installing Microsoft R Open.
You will find logs for this installation in
/microsoft-r-open/logs
起動
起動してみます。3.5.xになっていることと、最後の方に Microsoft R Open 3.5.x と表記されていることを確認します。
$ R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Microsoft R Open 3.5.1
The enhanced R distribution from Microsoft
Microsoft packages Copyright (C) 2018 Microsoft Corporation
Using the Intel MKL for parallel mathematical computing (using 1 cores).
Default CRAN mirror snapshot taken on 2018-08-01.
See: https://mran.microsoft.com/.
>
パッケージのインストール
Rが起動できたら使いそうなパッケージがインストールできて使えることを確認します。パッケージによってはコンパイルを伴うものもあるので念のため確認しておいた方がいいかなって思います。
以下は data.table をインストールする場合です。 /opt に書き込める権限がない場合はローカルにインストールできますので、そのあたりを聞かれます。皆で共有する必要がなければ yes でいいと思います。
> install.packages("data.table")
Warning in install.packages("data.table") :
'lib = "/opt/microsoft/ropen/3.5.1/lib64/R/library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) yes
Would you like to create a personal library
‘~/R/x86_64-pc-linux-gnu-library/3.5’
to install packages into? (yes/No/cancel) yes
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3207k 100 3207k 0 0 1056k 0 0:00:03 0:00:03 --:--:-- 1056k
* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** libs
sh: 1: make: not found
Warning in system(cmd) : error in running command
ERROR: compilation failed for package ‘data.table’
* removing ‘~/R/x86_64-pc-linux-gnu-library/3.5/data.table’
The downloaded source packages are in
‘/tmp/RtmpmYkyTo/downloaded_packages’
Warning message:
In install.packages("data.table") :
installation of package ‘data.table’ had non-zero exit status
いきなりエラーのようで、どうも make
コマンドがないようです。以前R OpenじゃないRをインストールした際は、build-essential といったコンパイルに必要なパッケージもインストールされたと記憶しているのですが、どうもR Openはされないようです。apt
コマンドを使って build-essential をインストールします。
sudo apt install build-essential
インストール後、再度、インストールしてみます。同じような感じでインストールを試みてエラーになったら必要なパッケージをインストールして再度チャレンジみたいな感じでインストールしてきます。
今のところ私が使ったことのあるパッケージは全部インストールできましたのでRとの互換性は十分なようです。
メモ
Rとの違いは?
https://www.r-project.org/ のページでも最新のR3.5が公開されています。じゃあそれとの違いは?という事で調べてみました。
Rを起動して、 installed.packages()
を実行してみたところR Openは44個のパッケージがインストールされていて、Rの方は29個だったのでデフォルトでインストールされるパッケージはR Openの方が多いようです。
R Openで追加インストールされるパッケージは Packages Installed with Microsoft R Open ( https://mran.microsoft.com/rro/installed )でも確認できます。
checkpoint
curl
deployrRserve
doParallel
foreach
iterators
jsonlite
MicrosoftR
png
R6
RevoIOQ
RevoMods
RevoUtils
RevoUtilsMath
RUnit
自動で読み込まれるパッケージは?
R Openを自動で読み込まれるパッケージを調べてみました。Rとの違いは RevoUtils でしょうか。
> getOption("defaultPackages")
[1] "datasets" "utils" "grDevices" "graphics" "stats" "methods"
[7] "RevoUtils"
RevoUtils は R_DEFAULT_PACKAGES=NULL R
で起動しても読み込まれてしまうようです。
$ R_DEFAULT_PACKAGES=NULL R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
…(省略)
> getOption("defaultPackages")
[1] "RevoUtils"
R --vanilla
をして起動すると読み込まれないようです。起動時に表示されていた「Microsoft R Open 3.5.1」のメッセージも表示されなくなってしまいました。
$ R --vanilla
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> getOption("defaultPackages")
[1] "datasets" "utils" "grDevices" "graphics" "stats" "methods"
curlでダウンロードが失敗する
R Openには最初からcurlがインストールされているのでlibrary(curl)
とするだけでcurlが使えるのですが、httpsのページだと失敗してしまいます。
> library(curl)
> curl_fetch_memory("https://www.google.co.jp")
Error in curl_fetch_memory("https://www.google.co.jp") :
error setting certificate verify locations:
CAfile: microsoft-r-cacert.pem
CApath: none
いろいろと試してみたのですが解決策が見つからなかったので、仕方なく再度curlをインストールしました。結果として元々インストールされているcurlではなくCRANのcurlを使うこととなります。
install.packages("curl")
でインストールしてq()
で終了します。そしてRを起動しlibrary(curl)
を実行すると先ほどインストールしたcurlが読み込まれます。
> install.packages(curl)
> q() #一旦終了
> library(curl)
> curl_fetch_memory("https://www.google.co.jp")
$url
[1] "https://www.google.co.jp/"
$status_code
[1] 200
$headers
(省略)