一条指令装一下ggplot2,它竟然告诉我没这个包,这难道不是在欺负我?
> install.packages("ggplot2")
Installing package into ‘E:/software-data/RLibrary’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://mirrors.ustc.edu.cn/CRAN/src/contrib:
cannot open URL 'https://mirrors.ustc.edu.cn/CRAN/src/contrib/PACKAGES'
Warning: unable to access index for repository https://mirrors.ustc.edu.cn/CRAN/bin/windows/contrib/4.5:
cannot open URL 'https://mirrors.ustc.edu.cn/CRAN/bin/windows/contrib/4.5/PACKAGES'
Warning message:
package ‘ggplot2’ 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 怀疑人生,想起我6年前写的魔镜mirrorselect包(电梯:《魔镜魔镜告诉你,它上CRAN了》),果断测速,换个镜像。
> mirrorselect::get_mirror('CRAN', 'cn') -> m
> head(m)
[1] "https://mirrors.tuna.tsinghua.edu.cn/CRAN/" "https://mirrors.bfsu.edu.cn/CRAN/" "https://mirrors.pku.edu.cn/CRAN/"
[4] "https://mirrors.ustc.edu.cn/CRAN/" "https://mirrors.zju.edu.cn/CRAN/" "https://mirrors.qlu.edu.cn/CRAN/"
> length(m)
[1] 12
> mirrorselect::mirrorselect(m) -> st
> st
mirror speed
1 https://mirrors.hust.edu.cn/CRAN/ 0.13
2 https://mirrors.ustc.edu.cn/CRAN/ 0.14
3 https://mirrors.sustech.edu.cn/CRAN/ 0.14
4 https://mirrors.pku.edu.cn/CRAN/ 0.18
5 https://mirrors.nju.edu.cn/CRAN/ 0.23
6 https://mirror.lzu.edu.cn/CRAN/ 0.26
7 https://mirrors.sjtug.sjtu.edu.cn/cran/ 0.27
8 https://mirrors.nwafu.edu.cn/cran/ 0.28
9 https://mirrors.zju.edu.cn/CRAN/ 0.32
10 https://mirrors.qlu.edu.cn/CRAN/ 0.41
11 https://mirrors.bfsu.edu.cn/CRAN/ 0.53
12 https://mirrors.tuna.tsinghua.edu.cn/CRAN/ 0.55看上去华科最快,换上再试试,装包就丝滑了。
> options(repos = c(CRAN = "https://mirrors.hust.edu.cn/CRAN/"))
> install.packages("ggplot2")
Installing package into ‘E:/software-data/RLibrary’
(as ‘lib’ is unspecified)
trying URL 'https://mirrors.hust.edu.cn/CRAN/bin/windows/contrib/4.5/ggplot2_3.5.2.zip'
Content type 'application/zip' length 5016803 bytes (4.8 MB)
downloaded 4.8 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\HUAWEI\AppData\Local\Temp\RtmpS8YcTh\downloaded_packages
CRAN包,用install.packages("mirrorselect")就可以安装,让你下包接上大水管。