Skip to contents

@omit excludes example code from a test until the next tag. Use @resume to restart including code without creating an expectation.

Details

Use @omit to avoid redundant or noisy code:

#' @doctest
#'
#' @expect equal(0)
#' sin(0)
#'
#' @omit
#' curve(sin(x), 0, 2 * pi)
#'
#' @expect equal(1)
#' cos(0)

@omit is separate from \donttest and \dontrun tags in Rd files. This allows you to test code that would cause an error if run by R CMD CHECK. If you also want R CMD CHECK to skip your code, you should use \donttest{} separately (see writing R extensions).

Remember that the main purpose of examples is to document your package for your users. If your code is getting too different from your example, consider splitting it off into a proper test file. You can do this by renaming it and deleting the Generated by doctest comment.