简体   繁体   English

在R中的install.packages()时选择CRAN镜像的目的?

[英]Purpose of selecting a CRAN mirror when install.packages() in R?

Most CRAN packages are <100mb and are consistent across mirrors, hence speed and/or consistency would be unlikely candidates. 大多数CRAN软件包的大小都小于100mb,并且在各个镜像之间都是一致的,因此速度和/或一致性不太可能成为候选。

For context, an extremely simple terminal command like R -e 'install.packages("testthat")' errors with 就上下文而言,一个非常简单的终端命令,例如R -e 'install.packages("testthat")'错误

Error in contrib.url(repos, "source") : 
  trying to use CRAN without setting a mirror
Calls: install.packages -> contrib.url
Execution halted

whereas most R users would expect that code to work, since they'll have run it from R scripts, and from the R interpreter (or rstudio). 而大多数R用户则希望该代码能够正常工作,因为他们已经从R脚本和R解释器(或rstudio)运行了该代码。

What is the purpose of forcing mirror selection? 强制选择镜像的目的是什么? (it may sound rhetorical but I am genuinely curious) (这听起来很夸张,但我真的很好奇)

Setting a CRAN mirror can explicitly tell R where to retrieve sources from. 设置CRAN镜像可以明确告诉R从何处检索源。

Please choose a location close to you. 请选择您附近的位置。

The above line, from https://cran.r-project.org/mirrors.html , hints that selecting a close mirror is wise. 上一行来自https://cran.r-project.org/mirrors.html ,暗示选择一个关闭的镜像是明智的。 This is because it can increase speed for which you download as well as reducing stress on the CRAN servers. 这是因为它可以提高下载速度,并减轻CRAN服务器的压力。 For information on how to do that, see this thread: How to select a CRAN mirror in R 有关如何执行此操作的信息,请参见以下线程: 如何在R中选择CRAN镜像

Sure this could be programmed into it, but it is a simple enough step to get people more involved with their R setup. 当然可以将其编程到其中,但这是使人们更多地参与其R设置的足够简单的步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM