简体   繁体   English

R:apt-get install r-cran-foo与install.packages(“foo”)

[英]R: apt-get install r-cran-foo vs. install.packages(“foo”)

When installing R packages (say mcmcpack in this example) under Ubuntu I have the choice between the following two methods of installation: 在Ubuntu下安装R软件包(比如本例中的mcmcpack )时,我可以选择以下两种安装方法:

# Let the distribution's packaging system take care of installation/upgrades
apt-get install r-cran-mcmcpack

# Let R take care of installation/upgrades
install.packages("mcmcpack")

Questions: 问题:

  • Is any of the two ways of installing R packages considered "best practice"? 安装R软件包的两种方法中的任何一种都被认为是“最佳实践”吗?
  • Assume that I first install.packages("mcmcpack") and later on apt-get install r-cran-mcmcpack - should I expect trouble? 假设我首先install.packages("mcmcpack")以及稍后的apt-get install r-cran-mcmcpack - 我应该遇到麻烦吗?
  • Assume that I first apt-get install r-cran-mcmcpack and later on install.packages("mcmcpack") - should I expect trouble? 假设我首先apt-get install r-cran-mcmcpack以及稍后的install.packages("mcmcpack") - 我应该遇到麻烦吗?

It's not as easy as it seems. 它并不像看起来那么容易。

  • apt-get update is good if and when apt-get update是好的,如果有的话

    • packages exist -- but there are only around 150 or so r-cran-* packages out of a pool of 2100+ packages on CRAN, so rather sparse coverage 包存在 - 但CRAN上的2100+包中只有大约150个r-cran-*包,因此覆盖范围r-cran-*

    • packages are maintained, bug free and current 包维护,无bug和当前

    • you are happy enough with the bi-annual releases by Ubuntu 你对Ubuntu的双年度发布很开心

  • install.packages() and later update.packages() is good if and when install.packages()和更高版本update.packages()是好的,如果时间

    • you know what it takes to have built-time dependencies (besides r-base-dev ) installed 你知道安装了构建时依赖项(除了r-base-dev )需要什么

    • you don't mind running update.packages() by hand as well as the apt-get updates. 你不介意手动运行update.packages()以及apt-get更新。

On my Ubuntu machine at work, I go with the second solution. 在我工作的Ubuntu机器上,我使用第二种解决方案。 But because the first one is better if you have enough coverage , we have built cran2deb which provides 2050+ binary deb packages for amd64 and i386 --- but only for Debian testing. 但是因为如果你有足够的覆盖率 ,第一个更好,我们已经构建了cran2deb ,它为amd64和i386提供了2050多个二进制deb包 - 但仅用于Debian测试。 That is what I use at home. 这就是我在家里使用的。

As for last question of whether you 'should you expect trouble': No, because R_LIBS_SITE is set in /etc/R/Renvironment to be 至于你是否应该“期待麻烦”的最后一个问题:不,因为R_LIBS_SITE/etc/R/Renvironment设置为

# edd Apr 2003  Allow local install in /usr/local, also add a directory for
#               Debian packaged CRAN packages, and finally the default dir 
# edd Jul 2007  Now use R_LIBS_SITE, not R_LIBS
R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:\
/usr/lib/R/site-library:/usr/lib/R/library'}

which means that your packages go into /usr/local/lib/R/site-library whereas those managed by apt go into /usr/lib/R/site-library and (in the case of base packages) /usr/lib/R/library . 这意味着你的包进入/usr/local/lib/R/site-libraryapt管理的包进入/usr/lib/R/site-library和(在基本包的情况下) /usr/lib/R/library

Hope that clarifies matters. 希望澄清问题。 The r-sig-debian mailing list is a more informed place for questions like this. 对于像这样的问题,r-sig-debian邮件列表是一个更加知情的地方。

  • I'd consider using apt-get best practice since you will get automatic updates through the standard system tools. 我会考虑使用apt-get最佳实践,因为您将通过标准系统工具获得自动更新。

  • Having 2 versions installed might get you into confusing situations: depending on your R setup you could load another package version then you expect -- your private (maybe outdated) one should in general be loaded first. 安装了2个版本可能会让您陷入困惑的情况:根据您的R设置,您可以加载另一个软件包版本然后您期望 - 您的私有(可能已过时)应该首先加载。

  • See above. 往上看。

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

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