EVOLUTION-MANAGER
Edit File: assert_that.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Assert that certain conditions are true.</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for assert_that {assertthat}"><tr><td>assert_that {assertthat}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Assert that certain conditions are true.</h2> <h3>Description</h3> <p><code>assert_that</code> is a drop-in replacement for <code><a href="../../base/html/stopifnot.html">stopifnot</a></code> but is designed to give informative error messages. </p> <h3>Usage</h3> <pre> assert_that(..., env = parent.frame(), msg = NULL) see_if(..., env = parent.frame(), msg = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>unnamed expressions that describe the conditions to be tested. Rather than combining expressions with <code>&&</code>, separate them by commas so that better error messages can be generated.</p> </td></tr> <tr valign="top"><td><code>env</code></td> <td> <p>(advanced use only) the environment in which to evaluate the assertions.</p> </td></tr> <tr valign="top"><td><code>msg</code></td> <td> <p>a custom error message to be printed if one of the conditions is false.</p> </td></tr> </table> <h3>Assertions</h3> <p>Assertion functions should return a single <code>TRUE</code> or <code>FALSE</code>: any other result is an error, and <code>assert_that</code> will complain about it. This will always be the case for the assertions provided by <code>assertthat</code>, but you may need be a more careful for base R functions. </p> <p>To make your own assertions that work with <code>assert_that</code>, see the help for <code><a href="on_failure.html">on_failure</a></code>. Alternatively, a custom message can be specified for each call. </p> <h3>See Also</h3> <p><code><a href="validate_that.html">validate_that</a></code>, which returns a message (not an error) if the condition is false. </p> <h3>Examples</h3> <pre> x <- 1 # assert_that() generates errors, so can't be usefully run in # examples ## Not run: assert_that(is.character(x)) assert_that(length(x) == 3) assert_that(is.dir("asdf")) y <- tempfile() writeLines("", y) assert_that(is.dir(y)) assert_that(FALSE, msg = "Custom error message") ## End(Not run) # But see_if just returns the values, so you'll see that a lot # in the examples: but remember to use assert_that in your code. see_if(is.character(x)) see_if(length(x) == 3) see_if(is.dir(17)) see_if(is.dir("asdf")) see_if(5 < 3, msg = "Five is not smaller than three") </pre> <hr /><div style="text-align: center;">[Package <em>assertthat</em> version 0.2.1 <a href="00Index.html">Index</a>]</div> </body></html>