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!
R objects are documented in files written in “R documentation” (Rd) format, a simple markup language much of which closely resembles (La)TeX, which can be processed into a variety of formats, including LaTeX, HTML and plain text.
Creating Rd Files You can create a new Rd file for an existing function, dataset, or other object in two ways: Call the prompt or promptData function, and then move the resulting Rd file into the man directory. Use the File -> New -> R Documentation command in RStudio.
To add documentation to an R package, you need to create a subdirectory “ man ” containing a set of files, one per function, in a special R Documentation format ( . Rd ). These will be the source for the documentation for each function; R processes them to create plain text, PDF, and HTML versions.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With