Linux環境下搭建R計算平臺

      R語言已經廣泛地應用於數據分析與文本挖掘,Facebook與Google的挖掘工具都是R語言,它較之於S-Plus與SAS具有開源等優勢,具能佈置於雲平臺下進行計算工作。與Matlab等一樣,R語言也是從Linux下向Windows發展,但由於許多的R語言程序包只能在Linux下才能用,今天我特意在個人的電腦上搭建了VMware虛擬機下的Fedora14系統,進行實驗。

Step1:VMware下搭建Fedora

    安裝VMware Station後在虛擬機的平臺上安裝Fedora14-i686.iso包,過程不再贅述!

    具體的安裝參考可見:http://blog.csdn.net/ppzlyg/article/details/4957792

安裝R有兩種方法,一種是取rpm包,另一種方法則是通過安裝R-2-15-1.tar.gz文件。

Step 2:安裝R語言環境

方法一:

    1、下載R語言包(http://cran.r-project.org/bin/linux/redhat/fedora11/i386/),把目錄下所有的.rpm文件都下載到一個文件夾中,如/home/libing/R下。我用的是Fedora,並且是32位機,所以選擇這個。如果是64位機,則應該選擇X86-64文件夾下的.rpm文件。

    2、安裝之前的準備工作:

         R語言在安裝之前,有許多的依賴包要用,所以這個步驟是用yum安裝這些依賴包

         a.  安裝gcc g++ gfortran編譯器:

                   yum install gcc

                   yum install gcc-c++

                   yum install gcc-gfortran

         b.  yum install pcre-devel

               yum install tcl-devel

               yum install zlib-devel

               yum install bzip2-devel

               yum install libX11-devel

               yum install readline-devel    #否則報”–with-readline=yes (default) and headers/libs are not available”錯誤
               yum install libXt-devel          #否則報”configure: error: –with-x=yes (default) and X11 headers/libs are not available”錯誤

               yum install tk-devel

               yum install tetex-latex

         c. 上面準備工作已經做好了,可以開始安裝R語言了:

               [root@rac1 linux_rpm]# rpm -ivh  libRmath-2.10.0-2.fc11.i586.rpm    

                [root@rac1 linux_rpm]# rpm -ivh  libRmath-devel-2.10.0-2.fc11.i586.rpm   //這兩步是安裝llibRmath包,直接安裝,沒有依賴包

               [root@rac1 linux_rpm]# rpm -Uvh R-core-2.10.0-2.fc11.i586.rpm     //安裝R-core時可能會發生錯誤,其Error信息如下:

                 

                          warning: R-core-2.10.0-2.fc11.i586.rpm:Header V3 DSA/SHA1 Signature, key ID 97d3544e: NOKEY

                          error: Failed dependencies:

                          libtcl8.4.so()(64bit) is needed by R-core-2.10.0-2.fc11.i586

                          libtk8.4.so()(64bit) is needed by R-core-2.10.0-2.fc11.i586

                          perl(File::Copy::Recursive) is needed by R-core-2.10.0-2.fc11.i586

                         --這裏安裝報錯,說要8.4 的tcl 包,實際我們已經通過yum安裝了8.5的,所以這裏我們可以強制安裝。

                         [root@rac1 linux_rpm]# rpm -qa|grep tcl

                          tcl-devel-8.5.7-6.fc11.i586

                          tcl-8.5.7-6.fc11.i586

                         強制安裝R-core:

                   [root@rac1 linux_rpm]# rpm -Uvh R-core-2.10.0-2.fc11.i586.rpm --force --nodeps

                            warning: R-core-2.10.0-2.fc11.i586.rpm:Header V3 DSA/SHA1 Signature, key ID 97d3544e: NOKEY

                            Preparing... ###########################################[100%]

                            1:R-core########################################### [100%]

                   [root@rac1 linux_rpm]# rpm -ivh R-devel-2.10.0-2.el5.x86_64.rpm   //安裝R-devel

                   [root@rac1 linux_rpm]# rpm -ivh R-2.10.0-2.el5.x86_64.rpm              //最後安裝R

          d.測試

               [root@rac1 ~]# xhost +

               access control disabled, clients canconnect from any host

               [root@rac1 ~]# R

               R version 2.10.0 (2009-10-26)

               Copyright (C) 2009 The R Foundation forStatistical Computing

               ISBN 3-900051-07-0

               R is free software and comes withABSOLUTELY NO WARRANTY.

               You are welcome to redistribute it undercertain conditions.

               Type 'license()' or 'licence()' fordistribution details.

               Natural language support but running in an English locale

               R is a collaborative project with manycontributors.

               Type 'demo()' for some demos, 'help()' foron-line help, or

               'help.start()' for an HTML browserinterface to help.

               Type 'q()' to quit R.

                >(接下來的操作與R在Windows相同)

 方法二:

           下載R-2-15.1.tar.gz文件,解壓

                            tar -zvxf  R-2-15.1.tar.gz   //生成了一個R-2-15-1的文件夾

                             cd R-2-15-1

                             ./configure

                              make

                              make install

              通過這種方法,比較簡單地就能安裝R.   在以後的安裝新包的過程中,使用指令 install.packages(“RODBC”) install.packages(“tseries”)即可矣!

Step 3:實驗操作,選擇一些只針對於Linux平臺才能發揮作用的一些R包進行操作實驗(未完待續!!!)



              

             

        



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章