
Last chance! 50% off unlimited learning
Sale ends in
Test whether variables in a data frame contain common NULL placeholders.
expect_text_miss(
vars,
miss = getOption("testdat.miss_text"),
flt = TRUE,
data = get_testdata()
)expect_text_nmiss(
vars,
miss = getOption("testdat.miss_text"),
flt = TRUE,
data = get_testdata()
)
expect_*()
functions are mainly called for their side effects. The
expectation signals its result (e.g. "success", "failure"), which is logged
by the current test reporter. In a non-testing
context the expectation will raise an error with class
expectation_failure
if it fails.
<tidy-select
> A set of columns to
test.
A vector of values to be treated as missing. The testdat.miss or testdat.miss_text option is used by default.
<data-masking
> A filter specifying
a subset of the data frame to test.
A data frame to test. The global test data is used by default.
Checks: text
Other data expectations:
conditional-expectations
,
datacomp-expectations
,
date-expectations
,
exclusivity-expectations
,
expect_depends()
,
generic-expectations
,
label-expectations
,
pattern-expectations
,
proportion-expectations
,
uniqueness-expectations
,
value-expectations
sales <- data.frame(
sale_id = 1:5,
date = c("20200101", "null", "20200102", "20200103", "null"),
sale_price = c(10, -1, 30, 40, -1)
)
# Dates not missing
try(expect_text_nmiss(date, data = sales))
# Date missing if price negative
try(expect_text_miss(date, flt = sale_price %in% -1, data = sales))
Run the code above in your browser using DataLab