目录
一、报错
在安装R包“ggalt”时,ggplot2有时也会出现这样的问题。这就是出现了镜像错误。遇到 “cannot open URL”
报错如下:
> install.packages("ggalt") Warning in install.packages : 无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib中读写索引: cannot open URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/PACKAGES' Warning in install.packages : 无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib中读写索引: cannot open URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/PACKAGES' Warning in install.packages : package ‘ggalt’ is not available for this version of R A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages Warning in install.packages : 无法在貯藏處https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.3中读写索引: cannot open URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.3/PACKAGES'
如上所述,无法找到有效的镜像。
二、解决
解决如下:
只需要在:
Tools->Global Options->Packages-> primary CRAN repository
选择其他的镜像即可,可以选择国内离自己最近的一个。
之后再次安装:
> install.packages("ggalt") 还安装相依关系‘proj4’, ‘ash’, ‘maps’ trying URL 'https://mirrors.sustech.edu.cn/CRAN/bin/windows/contrib/4.3/proj4_1.0-13.zip' Content type 'application/zip' length 6792629 bytes (6.5 MB) downloaded 6.5 MB trying URL 'https://mirrors.sustech.edu.cn/CRAN/bin/windows/contrib/4.3/ash_1.0-15.zip' Content type 'application/zip' length 31924 bytes (31 KB) downloaded 31 KB trying URL 'https://mirrors.sustech.edu.cn/CRAN/bin/windows/contrib/4.3/maps_3.4.1.1.zip' Content type 'application/zip' length 3098701 bytes (3.0 MB) downloaded 3.0 MB trying URL 'https://mirrors.sustech.edu.cn/CRAN/bin/windows/contrib/4.3/ggalt_0.4.0.zip' Content type 'application/zip' length 2357317 bytes (2.2 MB) downloaded 2.2 MB 程序包‘proj4’打开成功,MD5和检查也通过 程序包‘ash’打开成功,MD5和检查也通过 程序包‘maps’打开成功,MD5和检查也通过 程序包‘ggalt’打开成功,MD5和检查也通过
成功!!!
如有其他问题,欢迎探讨。