A specialized version of stopifnot()
for pointblank: stop_if_not()
Source: R/validate_rmd.R
stop_if_not.Rd
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.
See also
Other Utility and Helper Functions:
affix_date()
,
affix_datetime()
,
col_schema()
,
from_github()
,
has_columns()
Examples
# This checks whether the number of
# rows in `small_table` is greater
# than `10`
stop_if_not(nrow(small_table) > 10)
#> NULL
# 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)
#> NULL