combination of \dontrun and \donttest?

Viewed 239

I have bits of code that I want to show in the examples of a package but neither run (when example(my_fun) is run) nor test (when R CMD check is run) because they're slow enough to annoy users who might unthinkingly run them, and definitely slow enough to annoy the CRAN maintainers.

Writing R Extensions says

You can use \dontrun{} for text that should only be shown, but not run ...

and

Finally, there is \donttest, used (at the beginning of a separate line) to mark code that should be run by example() but not by R CMD check.

Should I nest these, i.e.

\donttest
\dontrun{first slow example ...}
\dontrun{second slow example ...}

? That technically seems to go against the wording in WRE (i.e. it says that \donttest code should be run by example() ...) ?

I could just include them in the examples in a commented-out form or using if (FALSE) { ... } if it came to it ... but that seems ugly.

1 Answers

\dontrun subsumes \donttest: code that is marked with the former will neither be run by example(), nor by R CMD check. I know this because my packages for talking to Azure use \dontrun liberally, for examples that assume you have an Azure account.

Related