加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

不需要命名空间依赖项

发布时间:2020-12-14 01:03:22 所属栏目:百科 来源:网络整理
导读:我试图构建一个R包,这样阅读CRAN手册。 我可以知道,使用导入来加载命名空间中的函数是最好的在描述文件中使用。 添加到描述文件后,我也将其添加到命名空间文件。 我将importFrom添加到具有所需函数的命名空间文件。 现在当我运行R CMD检查我的包, 我得到
我试图构建一个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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读