| stop_if_not | R Documentation |
stopifnot() for pointblank: stop_if_not()This variation of stopifnot() works well as a standalone replacement for
stopifnot() but is also customized for use in validation checks in R
Markdown documents where pointblank is loaded and validate_rmd() is
invoked. Using stop_if_not() in a code chunk where the validate = TRUE
option is set will yield the correct reporting of successes and failures
whereas stopifnot() does not.
stop_if_not(...)
... |
R expressions that should each evaluate to (a logical vector of
all) |
NULL if all statements in ... are TRUE.
13-5
Other Utility and Helper Functions:
affix_date(),
affix_datetime(),
col_schema(),
from_github(),
has_columns()
# This checks whether the number of
# rows in `small_table` is greater
# than `10`
stop_if_not(nrow(small_table) > 10)
# This will stop for sure: there
# isn't a `time` column in `small_table`
# (but there are the `date_time` and
# `date` columns)
# stop_if_not("time" %in% colnames(small_table))
# You're not bound to using tabular
# data here, any statements that
# evaluate to logical vectors will work
stop_if_not(1 < 20:25 - 18)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.