run_examples: Run all examples in a package.

Description Usage Arguments See Also

View source: R/run-examples.r


One of the most frustrating parts of 'R CMD check' is getting all of your examples to pass - whenever one fails you need to fix the problem and then restart the whole process. This function makes it a little easier by making it possible to run all examples from an R function.


run_examples(pkg = ".", start = NULL, show = TRUE, test = FALSE,
  run = TRUE, fresh = FALSE)



package description, can be path or package name. See as.package for more information


Where to start running the examples: this can either be the name of Rd file to start with (with or without extensions), or a topic name. If omitted, will start with the (lexicographically) first file. This is useful if you have a lot of examples and don't want to rerun them every time you fix a problem.


if TRUE, code in \dontshow{} will be commented out


if TRUE, code in \donttest{} will be commented out. If FALSE, code in \testonly{} will be commented out.


if TRUE, code in \dontrun{} will be commented out.


if TRUE, will be run in a fresh R session. This has the advantage that there's no way the examples can depend on anything in the current session, but interactive code (like browser) won't work.

See Also

Other example functions: dev_example

devtools documentation built on May 19, 2017, 8:55 p.m.
Search within the devtools package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.