Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 674
alittleboy Avatar asked Sep 16 '12 18:09

alittleboy


People also ask

What are .RD files?

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.

How do I create an RD File?

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.

How do I write R package documents?

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.


1 Answers

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

  • a manual translation or
  • the rd2roxygen package.
like image 131
Dirk Eddelbuettel Avatar answered Nov 15 '22 18:11

Dirk Eddelbuettel