最近在尝试做R包的开发,在DESCRIPTION 文件中的Depends和Imports没有完全弄明白两者的区别。看了谢老大的“开发R程序包之忍者篇http://cos.name/2011/05/write-r-packages-like-a-ninja/”也没有理解透?请大家再帮忙解释解释。

谢谢!

1.1.1 The DESCRIPTION file

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 3.0.0 or later, include ‘R (>= 3.0.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.

A package (or ‘R’) can appear more than once in the ‘Depends’ field.

It makes no sense to declare a dependence on R without a version specification, nor on the package base: this is an R package and base is always available.

The ‘Imports’ field lists packages whose namespaces are imported from (as specified in the NAMESPACE file) but which do not need to be attached. Namespaces accessed by the ‘::’ and ‘:::’ operators must be listed here, or in ‘Suggests’ or ‘Enhances’ (see below). Ideally this field will include all the standard packages that are used, and it is important to include S4-using packages (as their class definitions can change and the DESCRIPTION file is used to decide which packages to re-install when this happens). Packages declared in the ‘Depends’ field should not also be in the ‘Imports’ field. Version requirements can be specified and are checked when the namespace is loaded (but only in R >= 3.0.0).

source:1.1.1 The DESCRIPTION file http://cran.r-project.org/doc/manuals/r-release/R-exts.html or R-Extensions.pdf p.12