Skip to content

Learn full the details in in vignette('rd').

Key tags:

  • @description: A short description of the purpose of the function. Usually around a paragraph, but can be longer if needed.

  • @example {path}: Embed examples stored in another file.

  • @examples: Executable R code that demonstrates how the function works. Code must run without error.

  • @examplesIf {condition}: Run examples only when condition is TRUE.

  • @noRd: Suppress .Rd generation for a block. Use for documentation blocks that should only be visible in the source code.

  • @param {name} {description}: Describe a function input. Should describe acceptable input types and how it affects the output. description is usually one or two sentences but can be as long as needed. Document multiple arguments by separating their names with commas without spaces.

  • @returns {description}: Describe the function's output. Typically will be a 1-2 sentence description of the output type, but might also include discussion of important errors or warnings.

  • @title {title}: A one-line description of the function shown in various indexes. An explicit @title is not usually needed as by default it is taken from the first paragraph in the roxygen block.

  • @usage {function_call(arg1, arg2 = default, ...)}: Override the default usage generated by roxygen2. Only needed when roxygen2 fails to correctly derive the usage of your function.

Other less frequently used tags:

  • @details: Additional details about the function. Generally superseded by instead using a level 1 heading.

  • @rawRd {rd}: Insert literal text directly into the .Rd file.

  • @return {description}: Describe the function's output. Superseded in favour of @returns.

Usage

#' @description
#' @details
#' @example {path}
#' @examples
#' @examplesIf {condition}
#' @noRd
#' @param {name} {description}
#' @rawRd {rd}
#' @return {description}
#' @returns {description}
#' @title {title}
#' @usage {function_call(arg1, arg2 = default, ...)}

See also

Other documentation tags: tags-index-crossref, tags-rd-other, tags-reuse