安装R包的问题 [英] Problems with installation R packages

查看:75
本文介绍了安装R包的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Windows 用户.几周前,我安装了 R 和 Rstudio 以及许多软件包.今天有消息说没有安装新的软件包.

I'm a Windows user. A few weeks ago I installed R and Rstudio along with many packages. Today there was a message that new packages were not installed.

Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'

我重新安装了 R 但这并没有解决问题.

I reinstalled R but this did not solve the problem.

install.packages 中的警告:

Warning in install.packages :

  InternetOpenUrl failed: 'Can not connect to server'

推荐答案

这是在 R 和 RStudio 中偶尔出现的东西.RStudio 更改了很多设置,选项 "repos" 就是其中之一.在 Windows 上,添加了以下内容

This is something that pops up in R and RStudio only once in a while. RStudio changes quite a few settings, and the option "repos" is one of them. On Windows, the following is added

这不是 RStudio 添加这个额外的存储库.该存储库由 Brian Ripley 博士友情提供,用于由于某种原因无法在 CRAN 上提供的软件包(许可证,不是开箱即用的,需要额外的软件,...).这在设置中称为CRANextra":

It's not RStudio adding this extra repository. The repository is kindly provided by Dr. Brian Ripley for packages that for some reason can't be made available on CRAN (license, not building out of the box, requiring additional software, ...). This is called "CRANextra" in the settings:

> getOption("repos")
                                CRAN                            CRANextra 
         "https://cran.rstudio.com/" "http://www.stats.ox.ac.uk/pub/RWin" 
attr(,"RStudio")
[1] TRUE

所以 RStudio 在 Windows 上运行时会尝试访问特定的存储库,但该存储库过去曾出现过一些连接问题;它并不总是可以访问的,如果不能访问,则会发出您报告的警告.

So RStudio tries to access a specific repository when run on Windows, but that repository has had some connection issues in the past; it isn't always reachable, and when it's not, the warnings you report are issued.

您可以通过重置此选项来停止此警告:

You can get this warning to stop by resetting this option:

options(repos = "https://cran.rstudio.com") # or a repo of your choice.

允许您在没有警告的情况下安装软件包:

Which allows you to install packages without the warning:

> install.packages("fortunes")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/fortunes_1.5-4.zip'
Content type 'application/zip' length 202721 bytes (197 KB)
downloaded 197 KB

package ‘fortunes’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\Joris\AppData\Local\Temp\Rtmpu0febg\downloaded_packages

即使显示此警告,仍会从 rstudio CRAN 镜像安装软件包.警告是 报告为错误,RStudio 承诺会尽快解决.

Even when this warning is displayed, packages still get installed from the rstudio CRAN mirror. The warning is reported as a bug, and RStudio has promised to tackle it soon.

R 常见问题解答(最后一段):

一些在 Windows 上没有开箱即用的 CRAN 包,需要额外的软件,或者正在运送第三方库Windows 不能以 Windows 二进制文件的形式在 CRAN 上可用包.尽管如此,其中一些软件包可在https://www.stats.ox.ac.uk/上的CRAN extras"存储库酒吧/RWin/由 Brian D. Ripley 友情提供.请注意,此存储库是一个适用于 Windows 的 R 最新版本的默认存储库.

Some CRAN packages that do not build out of the box on Windows, require additional software, or are shipping third party libraries for Windows cannot be made available on CRAN in form of a Windows binary packages. Nevertheless, some of these packages are available at the "CRAN extras" repository at https://www.stats.ox.ac.uk/pub/RWin/ kindly provided by Brian D. Ripley. Note that this repository is a default repository for recent versions of R for Windows.

这篇关于安装R包的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆