Centos6.6 yum源更新方法及R软件安装,R模块安装
阅读原文时间:2021年04月20日阅读:1

新到的集群(centos 6.6)

准备安装些常用软件

yum install softwarename

安装第一个软件yum install R

发现找不到源路径,解决办法,更新yum源(来源https://blog.csdn.net/owangf_dl/article/details/78966369)

1、备份

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d//CentOS-Base.repo.ori

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

3、清理

 yum clean all

4、更新缓存

yum makecache
yum install tree -y
yum update -y

https://cran.r-project.org/ 下有linux下R安装说明:

sudo yum install R

安装完后显示complete,运行R,OK

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing

Platform: x86_64-redhat-linux-gnu (64-bit)

安装完后突然发现没有指定目录,不知道安装在到哪个目录下,查了下方法:

rpm -qal |grep "/R/" |less

发现,R目录在/usr/share/R /usr/include/R /usr/lib64/R 下面,安装目录主目录在/usr/lib64/R下,普通用户测试了下,R可用,/usr/lib64在默认的环境变量里。

使用普通用户来安装R包。

R进入R运行窗口, install.packages("ggplot2"), 目录无权写入,新建私有目录,安装即可,选择中国镜像

root账号直接安装即可,安装时间比较长,因为新安装的R软件,里面包少,安装ggplot2时安装的依赖包非常多。还好是在线,哈哈,要离线得一个一个依赖包去安装。

同时用root账号与普通账号安装的ggplot2包,root账号先完成,同样的网络,可能是普通账号前期有些文件要下载,root不用。

安装完后

library("ggplot2")

没报错即安装成功。

测试可用,安装的模块目录 /usr/lib64/R/library/ ,发现好多包了,很多是ggplot2的依赖包

assertthat  cli         compiler   digest   graphics   KernSmooth  magrittr  mgcv     parallel  RColorBrewer  rpart    stats    survival  translations
base        cluster     crayon     foreign  grDevices  labeling    MASS      munsell  pillar    Rcpp          scales   stats4   tcltk     utf8
boot        codetools   datasets   ggplot2  grid       lattice     Matrix    nlme     plyr      reshape2      spatial  stringi  tibble    utils

class       colorspace  dichromat  glue     gtable     lazyeval    methods   nnet     R6        rlang         splines  stringr  tools     viridisLite

安装完R及包后开始画图,保存图片为tiff格式时报错

No TIFF support in this version of R

暂时未解决

------------------------------------

查了下R tiff格式不能生成的解决方案。 进入R,看了下,tiff FALSE

有说可能是缺少一些库文件,于是安装

yum install libpng libpng-devel libtiff libtiff-devel libjpeg-turbo libjpeg-turbo-devel

提示已经是最新版本。

yum remove R卸载R后,重新安装库文件与R软件,进入R,tiff还是FALSE。尝试各种方案未解决。

使用替代方案:安装Cairo包。

install.packages("Cairo")

library(Cairo)

Cairo.capabilities()

输出tiff格式图片,采用 CairoTIFF(file="out.tiff",width=800,height=480)这样设置,暂时用此替代方案解决问题。

最终解决办法: yum安装tiff相关的各文件

yum install libtiff*

yum install tiff*

此时直接yum install R在线安装,tiff还为false。

进行编译安装时:Capabilities skipped: TIFF,直接跳出tiff安装,试用了R 3.4及R3.5版本,都有同样问题,google搜了好久没解决。

后下载R-3.2.5,通过编译安装(编译安装可以网上搜操作过程,很详细,需要安装很多依赖包),通过,未出现Capabilities skipped: TIFF,接续后续安装,问题解决。

平时不会出现的问题,遇到还比较麻烦,具体问题产生的原因还没理太清楚,可能是硬件,软件,gcc这些可能版本等问题。遇到同样问题的同学可以尝试用此方法来解决问题。中英文搜遍了全网,没有解决方案,得多尝试,终于解决了,耽误了好多时间。

问题总是没有终结的,问题解决的同时,新问题又产生了,重新安装R后,之前的包都没有了,重新安装

install.packages("ggplot2") 新问题出来了

checking with pkg-config for the system ICU4C… no
*** pkg-config did not detect ICU4C-devel libraries installed
*** Trying with "standard" fallback flags
checking whether we may build an ICU4C-based project… no
*** The available ICU4C cannot be used
checking whether we may compile src/icu61/common/putil.cpp… no
checking whether we may compile src/icu61/common/putil.cpp with -D_XPG6… no
*** The ICU4C bundle could not be build. Upgrade your compiler flags.
ERROR: configuration failed for package 'stringi'
* removing '/usr/local/lib64/R/library/stringi'
ERROR: dependency 'stringi' is not available for package 'stringr'
* removing '/usr/local/lib64/R/library/stringr'
ERROR: dependency 'stringr' is not available for package 'reshape2'
* removing '/usr/local/lib64/R/library/reshape2'

The downloaded source packages are in
        '/tmp/RtmpS2sPJy/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' … done
Warning messages:
1: In install.packages("reshape2") :
  installation of package 'stringi' had non-zero exit status
2: In install.packages("reshape2") :
  installation of package 'stringr' had non-zero exit status
3: In install.packages("reshape2") :
  installation of package 'reshape2' had non-zero exit status

单个安装stringi同样报错,搜解决方案:

install.packages(c("ggplot2"),configure.args=c("--disable-cxx11"),repos="https://cran.rstudio.com")

解决问题方案(https://github.com/gagolews/stringi/issues/296 发现有个点赞较高,试了可用)