23

I am converting my packages to use roxygen documentation, through the roxygen2 package. Now my package does not load and I think that is is because of the missing useDynLib(mypackage) call missing from the NAMESPACE file. How do I get this generated?

johannes
  • 14,043
  • 5
  • 40
  • 51
Andrew Redd
  • 4,632
  • 8
  • 40
  • 64
  • 7
    Off the top of my head is it `@useDynLib xyz` ? – hadley Dec 07 '11 at 02:32
  • yup. shame on my for not trying the obvious. – Andrew Redd Dec 07 '11 at 05:07
  • 1
    It wasn't totally obvious to me from the above (I guess it should have been) but that option needs to be added to the roxygen documentation entry for the package itself. This was helpful for me to see the example: https://ironholds.org/blog/adding-rcpp-to-an-existing-r-package-documented-with-roxygen2/ – Nicholas G Reich Jan 11 '17 at 16:37
  • The demo link appears to be broken, which is too bad because I also suffered from not knowing where to put the call – miratrix Feb 07 '18 at 16:04

1 Answers1

20

Start a package-level documentation file. In your example, R/mypackage.R that contains something like:

#' mypackage: A package for computating the notorious bar statistic.
#'
#' The mypackage package provides three categories of important functions:
#' foo, bar and baz.
#' 
#' @section Mypackage functions:
#' The mypackage functions ...
#'
#' @docType package
#' @name mypackage
#' @useDynLib mypackage
NULL
#> NULL

I also struggled for a bit to get .registration=TRUE. That is

#' @useDynLib mypackage, .registration=TRUE
dfrankow
  • 20,191
  • 41
  • 152
  • 214