Ken Williams
Ken Williams

Reputation: 24015

Roxygen: export imported function

I have an R package that was getting too big, so I split out a coherent chunk of it into a new package.

I want to provide a deprecation period for users who might have been relying on those functions, so I did this:

##' Blah blah function
##'
##' Deprecated - use `newpack::blah` instead.
##' @export
blah <- newpack::blah

One drawback is that R CMD CHECK warnings caused by newpack::blah are now warnings in this package:

Undocumented arguments in documentation object 'blah'
    ‘x’ ‘...’

What's a better way?

Upvotes: 2

Views: 251

Answers (1)

Ken Williams
Ken Williams

Reputation: 24015

Because of R's deep copying semantics, doing blah <- newpack::blah actually deeply copies the newpack::blah function into the current package, rather than just referring to it by name.

Instead of copying from one namespace to the other, import blah and re-export it:

##' Blah blah function
##'
##' Deprecated - use `newpack::blah` instead.
##' @importFrom newpack blah
##' @export blah
##' @name blah
NULL

Upvotes: 3

Related Questions