From h.wickham at gmail.com  Wed Aug 21 00:43:03 2013
From: h.wickham at gmail.com (Hadley Wickham)
Date: Tue, 20 Aug 2013 17:43:03 -0500
Subject: [Rd] Extending suggestion for stopifnot
In-Reply-To: <CAPr7RtX3b5XBzgn1XT3nPcvX71G=W1CpK=tK1T3zz4zWW=pQNQ@mail.gmail.com>
References: <CAPr7RtX3b5XBzgn1XT3nPcvX71G=W1CpK=tK1T3zz4zWW=pQNQ@mail.gmail.com>
Message-ID: <CABdHhvFTih=NGm=_PxJfTSO3g29HR=wPJWOYOxk5UmKFk2H52w@mail.gmail.com>

> 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/



[Rd] Extending suggestion for stopifnot
Hadley Wickham