制作只加载其他包并导出所有功能的 R 包
Make R-package that just loads other packages and exports all functions
是否可以制作一个只导出其他 R 包的所有函数的 R 包?有没有另一种方法可以在手册、代码文件等中对包中的函数进行相应的分类和排序?
是的,您可以拥有一个只为其依赖项调用的包。举一个突出的例子,now-archived gregmisc package 最初是不同函数的巨大集合,最终被分解成单独的包。虽然 gregmisc 在 CRAN 上仍然可用,但它不包含任何功能,只有这个启动功能:
.onAttach <- function(libname, pkgname)
{
packageStartupMessage(
"All functionality of the `gregmisc' package has been moved",
"into the four 'g' packages: gdata, gtools, gmodels, and gplots. ",
"This package is retained to make it easy to install and load",
"the full set. Please consider loading these packages directly."
)
}
然后简单地依赖于 DESCRIPTION 文件中描述的新的分离包:
Package: gregmisc
Title: Greg's Miscellaneous Functions
Description: Description: The former gregmisc bundle is a repository
for a variety of useful functions. The gregmisc package has
been split into a set of more focused packages: gdata, gmodels,
gplots, gtools. The purpose of this 'new' gregmisc is to
provide an easy way to access the original combined
functionality. To this end, it simply depends on all of the
new packages so that these will installed/loaded when this
package is installed/loaded.
Depends: gdata, gmodels, gplots, gtools
Version: 2.1.5
Author: Gregory R. Warnes.
Maintainer: Gregory R. Warnes <greg@warnes.net>
License: GPL-2
Packaged: 2013-06-28 21:48:38 UTC; warnes
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2013-06-29 00:15:57
是否可以制作一个只导出其他 R 包的所有函数的 R 包?有没有另一种方法可以在手册、代码文件等中对包中的函数进行相应的分类和排序?
是的,您可以拥有一个只为其依赖项调用的包。举一个突出的例子,now-archived gregmisc package 最初是不同函数的巨大集合,最终被分解成单独的包。虽然 gregmisc 在 CRAN 上仍然可用,但它不包含任何功能,只有这个启动功能:
.onAttach <- function(libname, pkgname)
{
packageStartupMessage(
"All functionality of the `gregmisc' package has been moved",
"into the four 'g' packages: gdata, gtools, gmodels, and gplots. ",
"This package is retained to make it easy to install and load",
"the full set. Please consider loading these packages directly."
)
}
然后简单地依赖于 DESCRIPTION 文件中描述的新的分离包:
Package: gregmisc
Title: Greg's Miscellaneous Functions
Description: Description: The former gregmisc bundle is a repository
for a variety of useful functions. The gregmisc package has
been split into a set of more focused packages: gdata, gmodels,
gplots, gtools. The purpose of this 'new' gregmisc is to
provide an easy way to access the original combined
functionality. To this end, it simply depends on all of the
new packages so that these will installed/loaded when this
package is installed/loaded.
Depends: gdata, gmodels, gplots, gtools
Version: 2.1.5
Author: Gregory R. Warnes.
Maintainer: Gregory R. Warnes <greg@warnes.net>
License: GPL-2
Packaged: 2013-06-28 21:48:38 UTC; warnes
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2013-06-29 00:15:57