读书人

Linux环境上搭建R计算平台

发布时间: 2012-08-30 09:55:54 作者: rapoo

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 -zcxf 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包进行操作实验(未完待续!!!)








读书人网 >UNIXLINUX

热点推荐