Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

combination of \dontrun and \donttest?

Tags:

package

r

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.

like image 975
Ben Bolker Avatar asked Sep 02 '25 07:09

Ben Bolker


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.

like image 117
Hong Ooi Avatar answered Sep 04 '25 21:09

Hong Ooi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!