The @examplesIf tag implements conditional examples, that do not run when running example() and R CMD check, unless some condition holds. You can use this mechanism to avoid running some examples on CRAN and/or during R CMD check, without adding boilerplate code to the examples themselves. The following example only runs if the computer is online:

#' @examplesIf curl::has_internet()
#' curl::curl_fetch_memory("")

If you never want to run an example, use FALSE as the condition. This makes sense for examples that take a very long time to run:

#' @examplesIf FALSE
#' some very long running computation...

To support @examplesIf in R6 classes you need to use the roxygenlabs_rd roclet. E.g. add this to DESCRIPTION:

Roxygen: { library(roxygenlabs); list(markdown = TRUE,
    roclets = c("collate", "namespace", "roxygenlabs_rd")) }

gaborcsardi/roxygenlabs documentation built on July 12, 2020, 9:41 p.m.