[Rd] Extending suggestion for stopifnot

Hadley Wickham h.wickham at gmail.com
Wed Aug 21 00:43:03 CEST 2013


> first, I think it would be more useful if it had an optional character
> string, so users could write
>
>   stopifnot( is.matrix(m), "m is not a matrix" )
>

Another option is to just generate better error messages automatically, e.g.:

> library(assertthat)
> x <- 1:10
> assert_that(is.matrix(x))
Error: x is not a matrix

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/



More information about the R-devel mailing list