- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于我编写的代码,我倾向于明确而不是隐含。因此,在设法创建自己的包之后,我立即想到的下一件事是如何最好地确保我的代码的健壮性和可靠性。其中一部分与我的包所依赖的包有关。
实际问题
在这方面:是否可以明确说明需要/需要哪个版本的包依赖项?
我正在寻找不需要说明实际路径的方法,例如 zip
文件(当然这很容易实现),但只需使用 install.packages
说明包名称的“标准行为”只有 (可能有一些所需版本的引用)。
尽职调查
我查过 Writing R Extensions看看我对 Depends
的选择是什么DESCRIPTION
的部分文件,希望有一个类似的机制来说明所需的 R 版本(例如 R (>= 2.15.2)
)。但我没有发现任何类似的包依赖项:
The ‘Depends’ field gives a comma-separated list of package names which this package depends on. The package name may be optionally followed by a comment in parentheses. The comment should contain a comparison operator, whitespace and a valid version number.
You can also use the special package name ‘R’ if your package depends on a certain version of R — e.g., if the package works only with R version 2.11.0 or later, include ‘R (>= 2.11.0)’ in the ‘Depends’ field. You can also require a certain SVN revision for R-devel or R-patched, e.g. ‘R (>= 2.14.0), R (>= r56550)’ requires a version later than R-devel of late July 2011 (including released versions of 2.14.0). Both library and the R package checking facilities use this field: hence it is an error to use improper syntax or misuse the ‘Depends’ field for comments on other software that might be needed. Other dependencies (external to the R system) should be listed in the ‘SystemRequirements’ field, possibly amplified in a separate README file.
The R INSTALL facilities check if the version of R used is recent enough for the package being installed, and the list of packages which is specified will be attached (after checking version requirements) before the current package, both when library is called and when preparing for lazy-loading during installation.
然后我也看了个install.packages
并希望像version
这样的东西争论,但我想没有。
免责声明
我非常清楚我的问题的目标可能与 R 通过 CRAN 包存储库分发和安装包的理念形成对比,其中(至少我猜)某些包的新版本只是“覆盖”以前的版本和install.packages()
总是选择最新的可用。对最终用户隐藏版本特性也很有意义,以免使事情变得过于复杂。
然而,关于编写尽可能健壮的代码的目标,恕我直言,非常明确地陈述事情也是有意义的。或者至少可以选择这样做。
最佳答案
您确实使用了 Depends
.例如:
Depends: R (>= 2.15.0), foo (== 1.17-12)
foo
等于
1.17-12
.
x.yy-zz
的包
foo 。)
关于r - 可以声明包依赖项的显式版本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13267140/
我是一名优秀的程序员,十分优秀!