Skip to content

Best way to implement optional functions?

4 messages · Richard Cotton, Duncan Murdoch, Thierry Onkelinx

#
On 22 October 2015 at 22:55, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
I had the same issue with the assertive package: it was getting big,
and not everyone wanted all the functionality.

The solution was to create several smaller packages with individual
components of functionality, for example assertive.base contains the
bare-minimum functionality; assertive.numbers contains functionality
related to numbers, etc.

Then the assertive package imports all the functions from the
component packages and reexports them.

That way people who want a small footprint (mostly other package
developers) can specify only what they need, and people who don't care
(mostly end users) can just type library(assertive) and get access to
everything.
#
On 16/11/2015 4:00 AM, Richard Cotton wrote:
When you import and re-export functions, do they need to be documented 
in both places?  I forget if we have a simple way to say "this function 
is documented in that package", to avoid duplication.

Duncan Murdoch
#
Roxygen2 documents imported and re-exported functions. See
http://www.r-bloggers.com/roxygen2-5-0-0/

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-11-16 22:02 GMT+01:00 Duncan Murdoch <murdoch.duncan at gmail.com>:

  
  
6 days later
#
Yes, you do need at least a token about of documentation in both
packages.  I keep full documentation in the package where they
originate, and minimal documentation in the rexporting package.  The
roxygen code in the reexporting package looks like this:

#' Some function
#'
#' See \code{\link[originating_pkg]{some_function}}.
#' @name some_function
#' @export
NULL

I borrowed this idea from dplyr's reexporting of magrittr's pipe.
On 17 November 2015 at 00:02, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: