开发一套依赖R包的最佳做法 [英] Best practices for developing a suite of dependent R packages

查看:231
本文介绍了开发一套依赖R包的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始研究一系列的R包,所有这些都包含了大量的通用代码,它们包含在自己的包中,可以称之为 myPackageUtilities 。所以我有几个包

I am starting to work on a family of R packages, all of which share substantial common code which is housed in its own package, lets call it myPackageUtilities. So I have several packages

myPackage1 myPackage2 等等...

所有这些软件包都依赖于 myPackageUtilities 中的每个方法。有关实际的示例,请参阅 CRAN上的statnet 。这个想法是,未来的开发人员可能会创建 myPackageN ,而不必重新编写/复制所有支持代码,这个未来的开发人员可以简单地使用 mypackageUtilities 开始使用。

All of these packages depend on every method in myPackageUtilities. For a real-world example, please see statnet on CRAN. The idea is that a future developer might create myPackageN, and instead of having to re-write/duplicate all of the supporting code, this future developer can simply use mypackageUtilities to get started.

有并发症:

1) mypackageUtilities 中的代码的某些适用于最终用户,其余则用于内部开发。需要使用roxygen2正确记录最终用户代码。这个代码包括S3类和泛型,以及用户的各种帮助函数。

1) Some of the code in mypackageUtilities is intended for end-users, and the rest is for internal development purposes. The end-user code needs to be properly documented using roxygen2. This code includes both S3 classes and generics, as well as various helper functions for the user.

2)依赖程序包( myPackage1 myPackage2 等)可能会扩展在 myPackageUtilities 中定义的S3泛型。

2) The dependent packages (myPackage1, myPackage2, etc.) will likely extend S3 generics defined in myPackageUtilities.

我的问题是:组装所有这些的最好方法是什么?这里有两个自然(但非exhuastive)选项:

My question is: What is the best way to assemble all of this? Here are two natural (but non-exhuastive) options:


  1. 包含 mypackageUtilities 导入:对于所有依赖软件包,并强制用户单独加载 mypackageUtilities

  2. 包含 mypackageUtilities under Depends:对于所有依赖的包,并且对从 mypackageUtilities 导出的内容非常有选择性,以避免混乱搜索路径。所有内部(非导出)代码将必须通过 myPackage1 等中的 ::: 访问。 / li>
  1. Include mypackageUtilities under Imports: for all the dependent packages, and force users to separately load mypackageUtilities,
  2. Include mypackageUtilities under Depends: for all the dependent packages, and be very selective about what is exported from mypackageUtilities so as to avoid cluttering the search path. All of the internal (non-exported) code will have to accessed via ::: in myPackage1, etc.

我最初问过类似的问题

I originally asked a similar question over here, but quickly discovered the situation gets complicated quickly. For example:

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