**What is the idiomatic way to check and document function preconditions and postconditions in R?** I would consider `Eiffel`'s built in `require` and `ensure` constructs or `D`'s `in` and `out` blocks state of the art here, but most languages don't have these baked in so have developed best practices to approximate them.

By checking preconditions, I mean throwing some kind of runtime exception if data that doesn't meet the functions assumptions are passed in. Currently have a `stopifnot` statement for every precondition I can think of at the start of the function. The same applies for postconditions, but with respect to the return value rather than the parameters.

Furthermore, is there are standard way of documenting what these preconditions and postconditions are? For example, it is pretty standard to spell these out in JavaDoc comments in Java.

What are the best practices in R in this respect?