tags:

views:

111

answers:

1

a statement that checks if something is true and if not prints a given error message and exits

+12  A: 

stopifnot()

You may also be interested in packages like Runit and testthat for unit testing.

Harlan
thank you much!
Dan
Is there a way to control the error message that is reported if stopifnot() stops?
Nick
@Nick, no. Use `stopifnot()` for validity testing, to test that code is doing what it's supposed to be doing, but `if (blahdiblah) stop("error message")` for input testing, to test that the input to the program is valid. Only the latter should ever happen during normal use.
Harlan