stopifnot(...)
| ... | One or more logical expressions that should evaluate to TRUE. Logical vectors must contain only TRUE values. |
z <- function(x)
{
stopifnot(length(x) > 0, log(x) > 1)
exp(sum(log(x)))
}
z(10:12)
# [1] 1320
## Not run:
z(numeric(0))
# Error in z(numeric(0)) : length(x) > 0 is not TRUE
z(1:4)
# Error in z(1:4) : log(x) > 1 is not all TRUE
stopifnot(all.equal(pi, 3.14), all(1:10 < 12), "d" < "b")
# Error: all.equal(pi, 3.14) is not TRUE
stopifnot(all.equal(pi, 3.1415927), all(1:10 < 12), "d" < "b")
# Error: "d" < "b" is not TRUE
## End(Not run)