天天看點

Centos7 配置R環境

  1. 安裝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)
               
  2. 安裝編譯器
    sudo yum -y install gcc
    sudo yum -y install gcc-c++
    sudo yum -y install gcc-gfortran
               
  3. 安裝依賴包
    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
               
  4. 下載下傳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]
    
               
  5. 解壓R源碼包
    [[email protected] ~]# tar -zxvf R-3.4.2.tar.gz 
               
  6. 執行指令進行配置
    [[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
               
    Centos7 配置R環境
  7. 配置成功後,執行如下指令進行編譯并安裝
    [[email protected] R-3.4.2]# sudo make && make install
               
    Centos7 配置R環境
  8. 配置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
               
  9. 使環境變量立即生效,并驗證環境變量是否配置成功

    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代碼測試

–待續

繼續閱讀