# whenever() is designed to work with check_that()
df <- data.frame(x = 1:5, y = 6:10)
df |>
check_that(
whenever(is_observed = x > 3, then_expect = y > 8),
whenever(x %in% 2:3, y > 6, at_least = .50) # qualifying condition
)
# whenever() can also work outside check_that()
x <- 1:5
y <- 6:10
whenever(x > 3, y > 9, at_least = 1 / 2) # TRUE
Run the code above in your browser using DataLab