Skip to content
Prev 34304 / 63424 Next

unit testing for R packages?

I put unit test in the examples, using "\dontshow" to hide "stopifnot".  
Many help pages I've written contain code like the following: 


A <- functionDocumentedHere()
B <- manuallyComputedAnswer

\dontshow{stopifnot(}
all.equal(A, B)
\dontshow{)}


      I think it helps the documentation to include an example comparing 
a special case computed using a function with a manual computation.  
However, "stopifnot" contributes nothing to user understanding, so I 
hide it.  One could also use "\dontshow" to hide entire examples that 
check trivial details you think would not interest users. 


      Spencer
Seth Falcon wrote: