The next generation of stopifnot()
-type functions: stop_if_not()
Source: R/validate_rmd.R
stop_if_not.Rd
This is stopifnot()
but with a twist: it 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. 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_datetime()
,
affix_date()
,
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