Centos安装R语言
如果安装时报错,建议安装低版本的,我安装的是3.2.0,安装时没有报错;因为高版本很多的新功能,同时编译的时候需要很多高版本的程序支持,所以要提前将相关的依赖包安装好,不然会报错。
一、下载、安装
源码下载地址: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.2.0.tar.gz
[[email protected] ~]# tar -zxvf R-3.2.0.tar.gz
[[email protected] ~]# cd R-3.2.0
[[email protected] ~]# ./configure
[[email protected] ~]# make
[[email protected] ~]# make install
二、修改环境变量
[[email protected] bin]# vim /etc/profile
export PATH=/opt/R-3.2.0/bin:$PATH
[[email protected] bin]# source /etc/profile
测试:
三、安装画图软件包ggplot2
选择一个镜像源:
a.运行R,在R的命令行中输入:
install.packages(“ggplot”)
b.出现软件包不可用,可能时镜像的问题。可以选择换镜像:
options(“repos” = c(CRAN=”https://mirrors.tuna.tsinghua.edu.cn/CRAN/”))
c.如果依然不行,可以使用biocLite软件对包进行安装:
source(“http://bioconductor.org/biocLite.R”)
options(BioC_mirror=”http://mirrors.ustc.edu.cn/bioc/”)
biocLite(“ggplot2”)
安装过程中如果提醒需要更新部分旧的包,可以输入:a
d.通过上面的操作,就将ggplot安装好了。使用前需要先加载一下库:
library(“ggplot2”)