Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documenting R.oo classes/methods with Roxygen

Could someone point me to a good example of documenting R.oo classes/methods with Roxygen? In R.oo, classes/methods are created by calls to setConstructorS3() and setMethodS3(), so there is no function to document per-se. Do you simply create standard Roxygen function documentation, but place it on top of a NULL statement?

like image 296
SFun28 Avatar asked Aug 26 '11 00:08

SFun28


People also ask

What is Roxygen R?

The goal of roxygen2 is to make documenting your code as easy as possible. R provides a standard way of documenting packages: you write . Rd files in the man/ directory. These files use a custom syntax, loosely based on LaTeX. roxygen2 provides a number of advantages over writing .

How do you add Roxygen?

Inserting a skeleton - Do this by placing your cursor anywhere in the function you want to document and click Code Tools -> Insert Roxygen Skeleton (default keyboard shortcut Ctrl+Shift+Alt+R ).

Do R packages contain documentation?

One of the core requirements for R packages is that all exported functions, objects, and datasets have complete documentation.


1 Answers

I think,

  1. @usage are needed.
  2. A dot-dot-dot argument is needed in the MyMethod.ClassName function for S3 generic/method consistency.
  3. Not #' @export MyMethod.ClassName but rather #' @S3method MyMethod ClassName?

An example code:

#' Title.  More Info.
#'
#' @usage MyMethod(...)
#' @param this this.
#' @param someParam Param info.
#' @param ... other arguments.
#'
#' @rdname   MyMethod
#' @export   MyMethod
#' @name     MyMethod
NULL

#' @usage \method{MyMethod}{ClassName}(this, someParam, ...)
#' @return MyMethod.ClassName:
#' \code{NULL}
#'
#' @rdname   MyMethod
#' @S3method MyMethod ClassName
#' @name     MyMethod.ClassName
setMethodS3("MyMethod", "ClassName", appendVarArgs = FALSE, 
function(this, someParam, ...) {
  NULL
})
like image 174
Triad sou. Avatar answered Sep 21 '22 16:09

Triad sou.