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 byexample()
but not byR 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.
\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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With