因为在中国大陆安装R包,通常是切换镜像的,我会首先推荐清华的镜像给学生们,切换镜像的代码如下:
options()$repos
options()$BioC_mirror
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options()$repos
options()$BioC_mirror
最近在Ubuntu里面安装R包 tidyverse:,发现报错:
During startup - Warning message:
Setting LC_CTYPE failed, using "C"
ERROR: dependency 'rvest' is not available for package 'tidyverse'
* removing '/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.6/tidyverse'
原来是有一个依赖包,名字是rvest,缺失了。按照以往的惯例,缺啥就安装啥呗;
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/rvest_0.3.4.tar.gz'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/rvest_0.3.4.tar.gz'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/rvest_0.3.4.tar.gz': HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package 'rvest' failed
然后发现诡异的报错,是这个包无法被下载,这个时候我没有紧张,下意识的认为是清华镜像问题,所以我重新下载;
> install.packages('rvest')
Installing package into '/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.6'
(as 'lib' is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rvest_0.3.5.tar.gz'
Content type 'application/x-gzip' length 1129355 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
发现的确就没有问题了。
再次安装tidyverse也成功了。
这个下意识到底是怎么样的一个思考过程,我很难描述出来!