[Rd] how to keep the documents of private functions private

Hadley Wickham hadley at rice.edu
Sat Aug 25 22:47:16 CEST 2012


> To provide some background, a more general question is how to manage unexported (private) functions in an R package. I need to call them during the developing phase or even after the package is released (e.g., for debugging purpose or they may be needed by new functions), but I don’t want to export them (I’d like to keep the number of exported (public) functions to a minimum and present the users with only the functions that they need to know.)

The devtools package allows you to do load_all("path/to/package"),
which simulates installing the package and then loading it (but is
much faster, at the cost of being a somewhat imperfect simulation).
Because working with unexported functions is so useful during
development, it makes all them all available.  (And the development
version allows you to choose whether or not you want them available)

I typically generate documentation with inline source comments (using
roxygen2). If I want them to be turned into Rd files and accessible to
the user I use the roxygen comments (#'). If I just want them to be
available to me (and other developers), I just use # - then they're
available in the source, but not in the man/ directory.

Hadley

-- 
Assistant Professor
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-devel mailing list