不需要命名空间依赖项

我试图构建一个R包,这样阅读CRAN手册。
我可以知道,使用导入来加载命名空间中的函数是最好的在描述文件中使用。
添加到描述文件后,我也将其添加到命名空间文件
我将importFrom添加到具有所需函数的命名空间文件

现在当我运行R CMD检查我的包,
我得到一个错误

Namespace dependencies not required :
‘ggplot2’

更多信息:即使我将包添加到描述文件中的依赖,它们也不会被加载。

请帮助这个。

请在下面找到我的描述文件

Package: bigpackage

Type: Package

Title: Some title

Version: 1.0

Date: 2012-10-25

Author: Mayank Bansal

Maintainer: somename

Imports : R(>= 2.15.1),SweaveListingUtils( >=0.5.5),xtable(>=1.7-0),
brew(>=1.0-6),knitr(>=0.8),RHive(>= 0.0-6),ggplot2(>=0.9.2)
,brew,knitr

SystemRequirements : LaTeX(texi2dvi) must be present in the system to
create PDF reports

Description: Some Description

License: file LICENSE

LazyLoad: yes

ByteCompile: true

OS_type : unix

如果在NAMESPACE文件中使用import或importFrom,则应在DESCRIPTION文件的Imports部分中为该软件包创建一个条目(除非有必要使用Depends的原因,在这种情况下,该软件包应该有一个依赖项,而不是导入)

这里是Writing R Extensions的相关部分

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.

我做了一个单一的函数f的包。我做了一个NAMESPACE文件,具有相同的importFrom行,你说你在你的。

NAMESPACE文件

export("f")
importFrom("ggplot2","ggplot","geom_histogram")

在这一点上,如果我运行R CMD检查,如预期,我得到一个错误

Namespace dependency not required: ‘ggplot2’

但是,如果我添加Imports:ggplot2到DESCRIPTION,使我的DESCRIPTION文件如下,它通过R CMD检查没有问题。

DESCRIPTION文件

Package: anRpackage
Type: Package
Title: What the package does (short line)
Version: 1.0
Date: 2012-11-07
Author: Me
Maintainer: Who to complain to <yourfault@somewhere.net>
Description: More about what it does (maybe more than one line)
License: GPL
Imports: ggplot2

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...