Is it possible to make an R-package that just exports all functions from other R-packages? Is there another way to have the functions in a package categorized and ordered accordingly in the manual, code files etc.?
Asked
Active
Viewed 94 times
0
-
ordered other than alphabetically? you could write a function that checks to see if packages are installed, install if not, and put it in your own package. wouldnt a package that only did that be a little overkill? – rawr Apr 04 '15 at 20:34
-
If there are a lot of functions for different tasks that can be categorized in groups, an alphabetical order is pretty much useless unless you already know how the functions are supposed to be used and only have forgotten some minor details (and remember their name). And I also don't think it is very helpful to have all of the code in one single R folder if you want to find something in it. I really wished one could put the code files in subfolders and also generate the manual accordingly. A package that loads all packages that belong together seems to be the best solution currently possible. – tover Apr 05 '15 at 00:25
1 Answers
1
Yes, you can have a package that is invoked just for its dependencies. As a prominent example, the now-archived gregmisc package, which began as a huge collection of different functions, was eventually broken down into separate packages. While gregmisc was still available on CRAN it contained no functions, just this startup function:
.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."
)
}
And then simply had dependencies on the new separated packages described in the DESCRIPTION file:
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

Thomas
- 43,637
- 12
- 109
- 140