导读
新机中安装ggplot2遇到两个bug,如下:
1 | install.packages("ggplot2") |
1 2 3 4 5 6 7 8 9 | Warning in install.packages("ggplot2") : 'lib="C:/Program Files/R/R-3.6.3/library"'不可写 --- 在此連線階段时请选用CRAN的鏡子 --- Warning: 无法在貯藏處https://mirrors.e-ducation.cn/CRAN/src/contrib中读写索引: 无法打开URL'https://mirrors.e-ducation.cn/CRAN/src/contrib/PACKAGES' Warning: 无法在貯藏處https://mirrors.e-ducation.cn/CRAN/bin/windows/contrib/3.6中读写索引: 无法打开URL'https://mirrors.e-ducation.cn/CRAN/bin/windows/contrib/3.6/PACKAGES' Warning message: package ‘ggplot2’ is not available (for R version 3.6.3) |
1 设置library文件夹共享
解决'lib="C:/Program Files/R/R-3.6.3/library"'不可写的问题
1 | install.packages("ggplot2") |
1 2 3 4 5 6 7 8 | C:/Users/hutongyuan/Documents/R/win-library/3.6’ (因为‘lib’没有被指定) Warning: 无法在貯藏處https://mirrors.e-ducation.cn/CRAN/src/contrib中读写索引: 无法打开URL'https://mirrors.e-ducation.cn/CRAN/src/contrib/PACKAGES' Warning: 无法在貯藏處https://mirrors.e-ducation.cn/CRAN/bin/windows/contrib/3.6中读写索引: 无法打开URL'https://mirrors.e-ducation.cn/CRAN/bin/windows/contrib/3.6/PACKAGES' Warning message: package ‘ggplot2’ is not available (for R version 3.6.3) |
lib使用了默认路径,但是第二个问题依旧存在
2 设置setRepositories
参考:R语言 install.packages 无法读取索引
1 2 | setRepositories(addURLs = c(CRANxtras = "http://cran.at.r-project.org/")) |

然后就可以安装了