roxygen3 (version 0.1)

ExamplesTag-class: @example/@examples: provide examples.

Description

These two tags allow you to add examples to the documentation, either inline with @examples or by pointing to an external file with @example.

Arguments

Escaping rules

As with all roxygen blocks, latex comments, % are always escaped to \%. Backslash behaviour, code\, is special for @example and @examples. Backslahes will be escaped to \\ unless they are for the special macros (the only macros that can be used inside an example block): \dontrun, \donttest, \dontrun or \testonly.

Tag Usage

#' @examples
#'    a <- 1
#'    b <- 2
#'  @example path/to/example file

Examples

Run this code
x <- 1:10
a <- "\\link{mean}(x)"
a <- "before tab\tafter tab"

test <- "\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z"
stopifnot(test == paste("\\", letters, collapse = "", sep = ""))

x %% 2
x %/% 2

# A strangely named function
"%\\%" <- function(a, b) a + b
10 %\% 10

## Not run: 
#   a <- 1
#   # this code will not be run
# ## End(Not run)

  b <- 1
  # this code will with example(), but not by R CMD check


Run the code above in your browser using DataLab