本家様 https://www.r-project.org/
言わずもがなの「R」
パッケージとして登録されているのでyumで気軽にインストールできる.
各ディストリビューターでは
[root@centos7 ~]# yum list |grep R-core
R-core.x86_64 3.6.0-1.el7 epel
R-core-devel.x86_64 3.6.0-1.el7 epel
[root@centos7 ~]#
[root@rockylinux ~]# dnf --enablerepo=powertools list | grep R-core
R-core.x86_64 4.2.2-1.el8 epel
R-core-devel.x86_64 4.2.2-1.el8 epel
[root@rockylinux ~]#
ここではCentOS7でRを使ってみる
epelからRは得られるが、そのバージョンは「3.6.0」と若干古い.
古くても構わないなら「yum install R-core R-core-devel」でインストールが済む.
より最新の「R」を使いたい場合は自らコンパイルする必要がある.
その場合 EnvironmentModules を使ってバージョン違いを念頭に構築が望ましいのかも
っで
(centos7)
yum groupinstall "Development Tools"
yum install readline-devel libX11-devel libXt-devel bzip2-devel xz-devel pcre2-devel libcurl-devel \
tcl-devel tk-devel libjpeg-turbo-devel libicu-devel libtiff-devel cairo-devel java-1.8.0-openjdk-devel
(RHEL8系RockyLinux)
dnf groupinstall "Development Tools"
dnf install gcc-gfortran readline-devel libX11-devel libXt-devel bzip2-devel pcre2-devel libcurl-devel \
tcl-devel tk-devel libjpeg-turbo-devel libXmu-devel libtirpc-devel libicu-devel libtiff-devel cairo-devel \
java-1.8.0-openjdk-devel
dnf install --enablerepo=devel texinfo-tex texlive-fonts-tlwg.noarch texlive-fontspec.noarch
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Everything/x86_64/os/Packages/t/texlive-inconsolata-svn54512-65.fc38.noarch.rpm
dnf localinstall texlive-inconsolata-svn54512-65.fc38.noarch.rpm
(ubuntu20.04)
apt install build-essential
apt install gfortran libreadline-dev libz-dev libbz2-dev liblzma-dev libpcre2-dev libcurl4-openssl-dev libxt-dev
(ubuntu22.04)
apt install build-essential
apt install gfortran libreadline-dev zlib1g-dev libbz2-dev liblzma-dev libpcre2-dev libcurl4-openssl-dev libxt-dev libpng-dev libjpeg-dev libtiff-dev libcairo-dev libicu-dev default-jdk
[root@centos7 ~]# mkdir -p /apps/src && cd /apps/src
[root@centos7 src]# curl -O https://cran.r-project.org/src/base/R-4/R-4.3.2.tar.gz
[root@centos7 src]# tar xf R-4.3.2.tar.gz && cd R-4.3.2
[root@centos7 R-4.3.2]# ./configure --prefix=/apps/R-4.3.2 --enable-R-shlib
:
:
R is now configured for x86_64-pc-linux-gnu
Source directory: .
Installation directory: /apps/R-4.3.2
C compiler: gcc -std=gnu11 -g -O2
Fortran fixed-form compiler: gfortran -g -O2
Default C++ compiler: g++ -std=gnu++11 -g -O2
C++11 compiler: g++ -std=gnu++11 -g -O2
C++14 compiler:
C++17 compiler:
C++20 compiler:
C++23 compiler:
Fortran free-form compiler: gfortran -g -O2
Obj-C compiler:
Interfaces supported: X11, tcltk
External libraries: pcre2, readline, curl
Additional capabilities: PNG, JPEG, TIFF, NLS, cairo, ICU
Options enabled: shared R library, shared BLAS, R profiling
Capabilities skipped:
Options not enabled: memory profiling
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of vignettes and help pages
[root@centos7 R-4.3.2]# make && make check && make install
RHEL系なら「/etc/modulefiles」あたり、ubuntuなら「/etc/environment-modules/modules」にファイルを作る.
独自の場所「/apps/modulefiles」に置くなら「module use --append /apps/modulefiles」あるいは「module use --prepend /apps/modulefiles」の明記が必要
「/etc/modulefiles/R/4.3.2」
[root@centos7 ~]# vi /apps/modulefiles/R/4.3.2
#%Module1.0
set R /apps/R-4.3.2
prepend-path PATH $R/bin
setenv R_HOME_DIR $R
setenv R_LIBS_USER $env(HOME)/.R/%V
setenv R_ENVIRON_USER $env(R_LIBS_USER)/.Renviron
setenv R_PROFILE_USER $env(HOME)/.Rprofile
setenv R_HISTFILE $env(HOME)/.Rhistory
setenv R_HISTSIZE 65535
[root@centos7 ~]#
[saber@centos7 ~]$ module use --append /apps/modulefiles/
[saber@centos7 ~]$ module load R
[saber@centos7 ~]$ which R
/apps/R-4.3.2/bin/R
[saber@centos7 ~]$
[saber@centos7 ~]$ R --version
R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
(略
[saber@centos7 ~]$
パッケージで済ませるならこんな感じで。
https://cran.ism.ac.jp/bin/linux/ubuntu/を参照しながら
apt update 「apt update -qq」の「-qq」はログの表示を抑えますします
apt install --no-install-recommends software-properties-common dirmngr
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
「lsb_release -cs」の値が「focal」(ubuntu20.04の名称)として
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
「/etc/apt/sources.list」にリポジトリが追加される
リポジトリの削除は「add-apt-repository --remove 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'」
「https://cloud.r-project.org/bin/linux/ubuntu/focal-cran40/」が参照される. ここに「r-base-core_4.2.1」とかがあある
apt search r-base-core
インストールされるRの確認
apt install r-base
っでテスト
illya@ubuntu:~$ which R
/usr/bin/R
illya@ubuntu:~$ R --version
R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"
Copyright (C) 2022 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 the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
illya@ubuntu:~$
「/usr/bin/R」の中身を見るとshellスクリプトで「R_HOME_DIR」「R_SHARE_DIR」が定義され、Rの本体は「/usr/lib/R/bin/exec/R」のご様子
(ubuntu20.04)
apt install build-essential
apt install gfortran libreadline-dev libz-dev libbz2-dev liblzma-dev libpcre2-dev libcurl4-openssl-dev libxt-dev
root@ubuntu:~# mkdir -p /apps/src && cd /apps/src
root@ubuntu:/apps/src# wget https://cran.r-project.org/src/base/R-4/R-4.2.2.tar.gz
root@ubuntu:/apps/src# tar xf R-4.2.2.tar.gz && cd R-4.2.2
root@ubuntu:/apps/src/R-4.2.2# ./configure --prefix=/apps/R-4.2.2 --enable-R-shlib
root@ubuntu:/apps/src/R-4.2.2# make && make check && make install
これでインストールは完了.
あとはEnvironment Modulesの設定を行う