即将到来的NAMESPACE,Depends,Imports for 2.14.0(请定义/使用某些定义) [英] Upcoming NAMESPACE, Depends, Imports changes for 2.14.0 (some definitions/use please)

查看:81
本文介绍了即将到来的NAMESPACE,Depends,Imports for 2.14.0(请定义/使用某些定义)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您是软件包的作者,那么当我们在一周左右的时间内升级到2.14时,希望您对软件包结构的即将发生的变化了如指掌.更改之一是,所有软件包都将需要一个名称空间,如果您不制作一个,则会为您生成一个(R等效于您在美国的Miranda权利).因此,作为一名好公民,我正在努力弄清这一点.这是R-exts中的部分:

If you are a package author, you are hopefully well aware of upcoming changes in package structure when we move to 2.14 in about a week. One of the changes is that all packages will require a NAMESPACE, and one will be generated for you in the event you do not make one (the R equivalent of your Miranda rights in the US). So being good citizen I was trying to figure this out. Here is the section from R-exts:

1.6.5摘要–转换现有程序包

1.6.5 Summary – converting an existing package

总而言之,将现有包转换为使用名称空间 涉及几个简单的步骤:

To summarize, converting an existing package to use a namespace involves several simple steps:

标识公共定义并将其放入导出指令中. 识别S3样式的方法定义并编写相应的S3方法 声明.识别依赖关系并替换所有要求调用 导入指令(并在Depends和 导入DESCRIPTION文件的字段).替换.First.lib函数 带有.onLoad函数或useDynLib指令.

Identify the public definitions and place them in export directives. Identify S3-style method definitions and write corresponding S3method declarations. Identify dependencies and replace any require calls by import directives (and make appropriate changes in the Depends and Imports fields of the DESCRIPTION file). Replace .First.lib functions with .onLoad functions or useDynLib directives.

为确保我在这里做正确的事,有人可以给出简短的清晰定义/答案(我是通过同时提出几个小而又相关的问题来打破规则吗?).所有答案都应考虑到2.14,

To ensure I do the right thing here, can someone give a short clear definition/answer (am I breaking a rule by having several small but related questions together?). All answers should take 2.14 into account, please:

  1. R使用的NAMESPACE定义
  2. 是否有一种在构建和检查之前生成NAMESPACE的方法,还是我们一次进行b/c然后编辑自动创建的NAMESPACE?
  3. DESCRIPTION文件中"Depends:"和"Imports:"之间的区别.尤其是为什么我要在"Depends:"而不是"Imports:"中放入一个包,反之亦然?
  4. 听起来好像不再需要使用"require",尽管它没有这么说.这是正确的解释吗?

谢谢!

推荐答案

我在 https://github.com/hadley/devtools/wiki/命名空间.

要回答您的问题:

  1. 请参阅Dirk的答案.
  2. 使用roxygen2
  3. 现在,每个程序包都有一个名称空间,几乎没有理由使用Depends.
  4. require仅应用于加载建议的程序包
  1. See Dirk's answer.
  2. Use roxygen2
  3. Now that every package has a namespace there is little reason to use Depends.
  4. require should only be used to load suggested packages

这篇关于即将到来的NAMESPACE,Depends,Imports for 2.14.0(请定义/使用某些定义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆