asachet
asachet

Reputation: 6921

best practice to give access to third party function through own package

Like many here, I maintain a custom package with "my" convenience functions, for use mainly by me and occasionally by people I share code with.

What is the best practice to include in my package a function, as is, from another package?

Concretely, I really like cut2 from package Hmisc but I don't like to load Hmisc because of name conflicts (seriously, manage your imports!) and because I never use Hmisc besides the occasional cut2.

At the moment, I use this, which works:

#' Cut2 from Hmisc
#'
#' Shamelessly imported from Hmisc, which I don't like to load because of name collisions.
#' @seealso \link[Hmisc]{cut2}
#' @importFrom Hmisc cut2
#' @export
cut2 <- cut2

Upvotes: 1

Views: 54

Answers (1)

Jot eN
Jot eN

Reputation: 6416

Your propose is probably the best practice possible. The other way (which I like less) is to:

#' Cut2 from Hmisc
#'
#' Shamelessly imported from Hmisc, which I don't like to load because of name collisions.
#' @seealso \link[Hmisc]{cut2}
#' @export
cut2 <- Hmisc::cut2

You could read more at this page - http://kbroman.org/pkg_primer/pages/depends.html.

Upvotes: 1

Related Questions