[Rd] Best way to implement optional functions?

Richard Cotton richierocks at gmail.com
Mon Nov 23 11:24:55 CET 2015


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:
> On 16/11/2015 4:00 AM, Richard Cotton wrote:
>>
>> On 22 October 2015 at 22:55, Duncan Murdoch <murdoch.duncan at gmail.com>
>> wrote:
>>>
>>> I'm planning on adding some new WebGL functionality to the rgl package,
>>> but
>>> it will pull in a very large number of dependencies. Since many people
>>> won't
>>> need it, I'd like to make the new parts optional.
>>
>>
>>> Can people suggest other packages that solve this kind of problem in a
>>> good
>>> way?
>>
>>
>> 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.
>>
>
> 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



-- 
Regards,
Richie

Learning R
4dpiecharts.com



More information about the R-devel mailing list