R语言在ubuntu下的编译安装
一、下载R语言安装文件
源码地址:https://www.r-project.org/;访问[CRAN镜像站点](http://cran.r-project.org/mirrors.html),根据自身网络环境选择合适的源代码仓库
这里选择清华镜像地址。https://mirrors.tuna.tsinghua.edu.cn/CRAN/
从 Source Code for all Platforms 中获取所需源码 R-*. *. * . tar.gz 文件 R-3.3.1.tar.gz,并将其下载至 src 文件夹中
二、编译安装
tar xzvf R-3.3.1.tar.gz
cd R-3.3.1
./configure
这里遇到几个配置错误:
1、bzip2版本问题
checking bzlib.h presence... yes
checking for bzlib.h... yes
checking if bzip2 version >= 1.0.6... no
checking whether bzip2 support suffices... configure:
error: bzip2 library and headers are required
下载bzip2编译安装
cd ~/src
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
按照README. 直接make安装即可,并生成动态库。
make -f Makefile-libbz2_so
make clean
make
make -n install
make install
重新到R文件夹下运行./configure仍遇到新问题
2、遇到libcurl版本问题
checking libcurl version ... 7.19.7
checking curl/curl.h usability... yes
checking curl/curl.h presence... yes
checking for curl/curl.h... yes
checking if libcurl is version 7 and >= 7.28.0... no
configure: error: libcurl >= 7.28.0 library and headers are
required with support for https
下载curl,编译安装
cd ~/src
wget --no-check-certificate https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar xzvf curl-7.47.1.tar.gz
cd curl-7.47.1
./configure
make -j3
make install
将./configure执行于R文件夹中成功完成。首先出现了两个提示信息,并告知无法生成info文档以及PDF格式的文件。由于这些提示信息不会影响到我们的使用流程,请予以忽略。
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package
接着编译也顺利
make
sudo make install
R语言环境已成功安装:
R Version 3.3.1, released on June 21, 2016, featuring the theme "Bug in Your Hair"
© 2016 The R Foundation for Statistical Computing
System Platform: x86_64-pc-linux-gnu, supporting 64-bit architecture
To exit R, use the q() function.
三、R语言包安装
R语言包其实就相当于C语言的库文件。
1、查看包
R提示符下查看已经安装了哪些包
library()
2、在线安装
在R的控制台,输入,例如
install.packages("gridExtra") # 安装 gridExtra
3、批量列表安装
编辑R文件,然后运行该R文件,如
