参考: 点击打开链接
1. R在Windows下安装
。。。
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 (vim /etc/lsb-release),进入到precise/目录,找到r-base-core相关的文件,发现有不同的R的版本。
把这个软件源,增加到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
# 安装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的语言。