R的历史版本安装

浏览: 1949

前言

R语言软件包已进入到了3.0的时代,但有些第三方的R包还处于2.15的状态,没有及时升级,像RHadoop,RHive。我们要用这些R包的时候,就需要指定版本的R软件。

对于Windows来说,这是很简单的操作,只要安装不同的(exe)文件就行了;对于Linux系统,我们也需要手动的进行配置。不熟悉Linux同学,在这里就很容易卡住。所以,今天就讲一下,在Linux Ubuntu系统中,R语言软件包指定版本安装。

目录

  1. R在Windows中安装
  2. R在Ubuntu中安装
  3. R在Ubuntu中最新版本安装
  4. R在Ubuntu中指定版本安装

1. R在Windows中安装

通过R的官方网站http://cran.r-project.org/,我们可以下载Linux, MacOS, Windows系统的R语言安装包。

R在Windows系统中安装非常简单,双击下载的可执行文件(.exe),即可进行安装。

安装后,运行R语言的界面

Clipboard Image.png

2. R在Ubuntu中安装

本文基于的Linux是Ubuntu 12.04.2 LTS 64bit的系统,安装R语言软件包可以通过apt-get实现。

在Linux Ubuntu中安装R语言


#检查R是否已安装
~ R
The program 'R' is currently not installed. You can install it by typing:
sudo apt-get install r-base-core

# 根据提示安装R语言软件包
~ sudo apt-get install r-base-core

# 检查R的版本
~ R --version
R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
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 version 2.
For more information about these matters see
http://www.gnu.org/licenses/.

发现R安装的默认版本是2.14.1,这与本书的中R的版本是不符的,接下来我们希望安装最新版本R的软件包。

3. R在Ubuntu中最新版本安装

首先,删除Linux Ubuntu系统中原有的R软件包。


sudo apt-get autoremove r-base-core

接下来,我们找到一个Ubuntu的软件源镜像(http://mirror.bjtu.edu.cn/cran/bin/linux/ubuntu/) ,Linux Ubuntu 12.04对应的名字是precise,进入到precise/目录,找到r-base-core相关的文件,发现有不同的R的版本

Clipboard Image.png]

把这个软件源,增加到apt的sources.list文件中


# 在sources.list文件最下面,新加一行
~ sudo sh -c "echo deb http://mirror.bjtu.edu.cn/cran/bin/linux/ubuntu precise/ >>/etc/apt/sources.list"

#更新源
~ sudo apt-get update

#再次安装R语言软件包
~ sudo apt-get install r-base-core

# 检查R的版本
~ R --version
R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 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
http://www.gnu.org/licenses/.

这时我们就安装了,最新的R语言3.0.3版本。

4. R在Ubuntu中指定版本安装

由于本书中的例子,大部分是基于3.0.1完成的,RHadoop的例子是基于2.15.3完成的,因此我们还需要指定R的安装版本。

安装R的2.15.3版本


# 删除系统中原有的R软件包
~ sudo apt-get autoremove r-base-core

# 安装R的2.15.3版本
~ sudo apt-get install r-base-core=2.15.3-1precise0precise1

# 检查R语言软件包版本
~ R --version
R version 2.15.3 (2013-03-01) -- "Security Blanket"
Copyright (C) 2013 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
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
http://www.gnu.org/licenses/.

安装R的3.0.1版本


# 删除系统中原有的R软件包
~ sudo apt-get autoremove r-base-core

# 检查直接的版本
~ sudo apt-cache showpkg r-base

# 安装R的3.0.1版本
~ sudo apt-get install r-base-core=3.0.1-6precise0

# 检查R语言软件包版本
~ R --version
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 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
http://www.gnu.org/licenses/.

这样我们就可以很方便的,指定安装不同版本的R的语言。


作者介绍:

民生银行大数据中心数据分析师,前况客创始人兼CTO,10 年IT编程背景,获得多项SUN及IBM技术认证。丰富的互联网应用开发架构经验,精通R ,Java, Nodejs 多种编程语言,掌握大数据处理,数据挖掘等核心技术,有统计和金融的知识积累。熟悉金融二级市场、交易规则和投研体系。多次在互联网及数据分析大会中担任演讲嘉宾。著有《R的极客理想-工具篇》、《R的极客理想-高级开发篇》图书,新书《R的极客理想-量化投资篇》(即将出版),博客http://fens.me, Alexa全球排名70k。

推荐 1
本文由 张丹 创作,采用 知识共享署名-相同方式共享 3.0 中国大陆许可协议 进行许可。
转载、引用前需联系作者,并署名作者且注明文章出处。
本站文章版权归原作者及原出处所有 。内容为作者个人观点, 并不代表本站赞同其观点和对其真实性负责。本站是一个个人学习交流的平台,并不用于任何商业目的,如果有任何问题,请及时联系我们,我们将根据著作权人的要求,立即更正或者删除有关内容。本站拥有对此声明的最终解释权。

0 个评论

要回复文章请先登录注册