Centos7 配置R环境
-
安装java并配置环境变量
[[email protected] ~]# java -version java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
-
安装编译器
sudo yum -y install gcc sudo yum -y install gcc-c++ sudo yum -y install gcc-gfortran
-
安装依赖包
sudo yum -y install readline-devel sudo yum -y install libXt-devel sudo yum -y install bzip2-devel sudo yum -y install xz-devel.x86_64 sudo yum -y install libcurl-devel sudo yum -y install texinfo.x86_64 texlive-pdftex-doc.noarch tex texlive-scheme-basic
-
下载R源码
wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.4.2.tar.gz
[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.4.2.tar.gz --2019-03-06 13:16:00-- https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.4.2.tar.gz Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 30255544 (29M) [application/x-gzip] Saving to: ‘R-3.4.2.tar.gz’ 100%[===================================================================================================================================================>] 30,255,544 8.72MB/s in 3.3s 2019-03-06 13:16:07 (8.72 MB/s) - ‘R-3.4.2.tar.gz’ saved [30255544/30255544]
-
解压R源码包
[[email protected] ~]# tar -zxvf R-3.4.2.tar.gz
-
执行命令进行配置
[[email protected] ~]# cd R-3.4.2/ [[email protected] R-3.4.2]# sudo ./configure --prefix=/usr/local/R-3.4.2 --enable-R-shlib
-
配置成功后,执行如下命令进行编译并安装
[[email protected] R-3.4.2]# sudo make && make install
-
配置R环境变量
[[email protected] ~]# cd /etc/profile.d [[email protected] profile.d]# vim r.sh [[email protected] profile.d]# cat r.sh export R_HOME=/usr/local/R-3.4.2 export PATH=$PATH:$R_HOME/bin
-
使环境变量立即生效,并验证环境变量是否配置成功
source /etc/profile
[[email protected] ~]# R -bash: R: command not found [[email protected] ~]# source /etc/profile [[email protected] ~]# R R version 3.4.2 (2017-09-28) -- "Short Summer" Copyright (C) 2017 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. > q() Save workspace image? [y/n/c]: n
10.R代码测试
–待续