Description Escaping rules Tag Usage Examples
These two tags allow you to add examples to the documentation, either inline
with @examples
or by pointing to an external file with
@example
.
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
.
1 2 3 4 | #' @examples
#' a <- 1
#' b <- 2
#' @example path/to/example file
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.