I am using a variant of stopifnot a lot. can I suggest that base R extends its functionality? I know how to do this for myself. this is a suggestion for beginners and students. I don't think it would break anything.
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" ) this would mean that stopifnot would have to detect whether the last argument is a string. (I think stopifnot should have had only one condition, and one should have used all() to test multiple conditions, but this is a bridge that was already crossed.) upon failure, stopifnot should print the character string. that's it. A second enhancement would be a "smart string", which knows that everything inside {{...}} should be evaluated. stopifnot( is.matrix(m), "m is not a matrix, but a {{class(m)}}" ) my own programming variant looks even nicer, is.matrix(m) %or% "m is not a matrix but a {{class(m)}}" but requesting base R to add the %and% and %or% (or, better yet, 'and' and 'or') operators by default would be pushing my luck. /iaw ---- Ivo Welch (ivo.we...@gmail.com) ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel