但是今天有一个学员起初是下载R包无法联网,所以失败,根据我们的经验当然是options(download.file.method = 'libcurl')就轻轻松松解决啦,不过这次居然是仅仅是解决了R自带R包下载问题,使用BiocManager仍然是无法安装R包,如下所示: 当然就得根据关键词去搜索啦! > BiocManager::install("KEGG.db",ask = F,update = F) 第一次搜索以为是http和https的问题参考:https:///questions/33355444/r-when-trying-to-install-package-internetopenurl-failed 大概意思是让我修改镜像把所有的https都替换为http,步骤如下:
但是尝试了,失败! 第二次尝试以为是BiocManager的config文件所以根据搜索结果使用: config <- readLines("https:///config.yaml") 这个时候的报错让我恍然大悟 其实真正的问题还是在联网上面!也就是说options(download.file.method = 'libcurl')并没有完全解决问题。 配置R联网环境继续搜索R联网环境,这个时候发现了url.method这个配置的解决方案; options(download.file.method = 'libcurl') 果然,现在在Windows电脑里面R语言的安装R包和下载文件就OK啦。有趣的是,你每次都需要复制粘贴上面两行代码,或者你把它写入到你的R配置文件哦。 那么这两个参数到底是啥区别呢 首先看 download.file.method ,非常复杂:https://stat./R-manual/R-devel/library/utils/html/download.file.html Method to be used for downloading files. Current download methods are "internal", "wininet" (Windows only) "libcurl", "wget" and "curl", and there is a value "auto": see 'Details’ and 'Note’. 然后看,也很复杂:https://stat./R-manual/R-devel/library/base/html/options.html· character string: the default method for url. Normally unset, which is equivalent to "default", which is "internal" except on Windows. 接下来就继续安装R包吧使用管理员打开R哦,然后就 options()$repos 如果你还报错,就看看周围有没有大神帮你解决吧! |
|