当RCurl :: getURL是什么时,为什么install.packages和download.file不能正常工作?

时间:2016-04-24 15:07:50

标签: r

我在从互联网安装软件包时遇到问题:

> install.packages("qualV")
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://mirror.ibcp.fr/pub/CRAN/src/contrib
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://mirror.ibcp.fr/pub/CRAN/src/contrib
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib
Warning in install.packages :
  package ‘qualV’ is not available (for R version 3.2.2)
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://mirror.ibcp.fr/pub/CRAN/bin/windows/contrib/3.2
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2

我检查了存储库,代理和设置调试信息:

> options(internet.info = 0)
> options()$repos
                                CRAN                            CRANextra 
  "https://mirror.ibcp.fr/pub/CRAN/" "http://www.stats.ox.ac.uk/pub/RWin" 
attr(,"RStudio")
[1] TRUE
>
> Sys.getenv("http_proxy")
[1] ""
> Sys.getenv("https_proxy")
[1] ""

我已经取消选中:R-studio->Tools->Global Options->Use Internet Explorer library/proxy for HTTP(我也尝试过没有R-studio的纯R,结果相同)

似乎问题在于互联网访问:

> url.link <- "https://stat.ethz.ch/R-manual/R-devel/library/utils/html/download.file.html"
> content  <- download.file(url.link, destfile = "download.file.html")
trying URL 'https://stat.ethz.ch/R-manual/R-devel/library/utils/html/download.file.html'
Error in download.file(url.link, destfile = "download.file.html") : 
  cannot open URL 'https://stat.ethz.ch/R-manual/R-devel/library/utils/html/download.file.html'
In addition: Warning message:
In download.file(url.link, destfile = "download.file.html") :
  InternetOpenUrl failed: 'The server name or address could not be resolved'

这里有趣的部分,似乎问题不在于互联网访问:

> library(RCurl)
> content <- getURL(url.link)
> nchar(content)
[1] 13537

install.packages工作时,为什么download.filegetURL无效?

PS:操作系统是在公司笔记本上运行的Windows 7,因此安装了AV / FW,我无法禁用(我不是管理员)。

1 个答案:

答案 0 :(得分:0)

这是猜测。

我认为你有一个新版本的RStudio但是旧版本的R.根据我的经验,你可以安装包,如果你只是使用R,即不通过RStudio。我建议将R和RStudio更新到最新版本。

我认为问题出现是因为RStudio强制执行https,这只是在R的更高版本中引入的。