An error occurred when installing the R language package

Network installation

$ R
> install.packages("xxx")
> 选择 beijing 1(清华)

Error encountered! ! ! !

The installation package keeps failing

There is a prompt f (nzchar(SHLIB_LIBADD)) SHLIB_LIBADD else character()

A very strange error, the reason is that several versions of R have been installed with conda, and the configuration files are not correct.

$ find /path/to/conda -name Makeconf
# 找到所有的 R 配置文件
# 查看自己使用的是什么版本,例如我这里有这些
$ /home/zzz/miniconda3/pkgs/r-base-3.5.1-hce969dd_0/lib/R/etc/Makeconf
  /home/zzz/miniconda3/pkgs/r-base-3.6.1-h8900bf8_2/lib/R/etc/Makeconf
  /home/zzz/miniconda3/envs/python2.7/lib/R/etc/Makeconf
  /home/zzz/miniconda3/lib/R/etc/Makeconf
  
# 自己使用的是 3.5.1 ,而 conda/lib/R/etc 路径下的是 3.6.1的 Makeconf
$ mv /home/zzz/miniconda3/lib/R/etc/Makeconf \
    /home/zzz/miniconda3/lib/R/etc/Makeconf.backup
$ cp /home/xilab/miniconda3/pkgs/r-base-3.5.1-hce969dd_0/lib/R/etc/Makeconf \
    /home/zzz/miniconda3/lib/R/etc/Makeconf

# 重新安装所需的包即可
$ R 
> install.packages("xxx")

# 最后查看一下是否安装成功
> sort(.packages(all.available = TRUE))

Guess you like

Origin blog.csdn.net/qq_32115939/article/details/107860937