Best practices for developing a suite of dependent R packages

前端 未结 1 1528
我寻月下人不归
我寻月下人不归 2021-01-15 16:40

I am starting to work on a family of R packages, all of which share substantial common code which is housed in its own package, lets call it myPackageUtilities.

相关标签:
1条回答
  • 2021-01-15 17:39

    Welcome to the rabbit hole.

    You may be pleasantly surprised to learn that you can import a function from myPackageUtilities into myPackage1 and then export it from myPackage1 to make it accessible from the global environment.

    So, when you say that you have a function in myPackageUtilities that should be accessible by the end user when myPackage1 is loaded, this is what I would include in my documentation for fn_name in myPackage1

    #' @importFrom myPackageUtilities fn_name
    #' @export fn_name
    

    (See https://github.com/hadley/dplyr/blob/master/R/utils.r for an example)

    That still leaves the question of how to link to the original documentation. And I'm afraid I don't have a good answer for that. My current practice is to, essentially, copy the parameters documentation from the original source and then in my @details section write please see the documentation for \code{\link[myPackageUtilities]{fn_name}}

    In the end, I still think your best bet is to export everything from myPackageUtilities that will ever get used outside of myPackageUtilities and do a combination import-export in each package where you want a function from myPackageUtilities to be accessible from the global environment.

    0 讨论(0)
提交回复
热议问题