Search code examples
rpackageroxygen2

Package .Rd files using roxygen2 package


I have a question about creating an .Rd file for my R package using the roxygen2 package.

It is clear to me that, for documenting R functions, I can use C-c C-o in emacs to generate comments above the function, and then fill them out, followed by roxygenize("pkg"). In this way, I have .Rd files for the R functions. However, I am not sure how can I get .Rd file for the data examples and the package itself? Currently, I am using prompt("data") to generate data.Rd and promptPackage("pkg") to generate pkg-package.Rd. I have to put these files into the man folder, and then edit them separately. How can I document data and package in a similar way like documenting R functions using roxygen2?

Thank you very much!


Solution

  • For data, see this previous question on SO which suggests:

    #' This is data to be included in my package
    #'
    #' @name data-name
    #' @docType data
    #' @author My Name \email{blahblah@@roxygen.org}
    #' @references \url{data_blah.com}
    #' @keywords data
    NULL
    

    I would suspect that you can do the same for pkg-package.Rd. If it must be in roxygen format, consider