今天在一台新机器上使用RGui时需要安装一些包,但是不管安装哪个包都会提示错误:
> install.packages("VennDiagram")
--- 在此連線階段时请选用CRAN的鏡子 ---
Warning: 无法在貯藏處https://mirrors.tongji.edu.cn/CRAN/src/contrib中读写索引:
无法打开URL'https://mirrors.tongji.edu.cn/CRAN/src/contrib/PACKAGES'
Warning: 无法在貯藏處https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6中读写索引:
无法打开URL'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/PACKAGES'
Warning message:
package ‘VennDiagram’ is not available (for R version 3.6.1)
原来install.packages
这个函数是有选项的:参考官方文档(??install.packages
),注意repos选项。
Usage
install.packages(pkgs, lib, repos = getOption("repos"),
contriburl = contrib.url(repos, type),
method, available = NULL, destdir = NULL,
dependencies = NA, type = getOption("pkgType"),
configure.args = getOption("configure.args"),
configure.vars = getOption("configure.vars"),
clean = FALSE, Ncpus = getOption("Ncpus", 1L),
verbose = getOption("verbose"),
libs_only = FALSE, INSTALL_opts, quiet = FALSE,
keep_outputs = FALSE, ...)
问题解决,可以通过options
设置https换成http:
options(repos='http://cran.rstudio.com/')
> library(VennDiagram)
载入需要的程辑包:grid
载入需要的程辑包:futile.logger
......
解决了!