check_between: Check that values are within a set of bounds

Description Usage Arguments Value Examples

View source: R/checks.R

Description

Check that values are within a set of bounds

Usage

1
check_between(..., .strict_lower = FALSE, .strict_upper = FALSE)

Arguments

...

named arguments where each name is a column, and each value is a length-2 numeric vector of the form c(lower_bound, upper_bound)

.strict_lower

should the lower bound be strict?

.strict_upper

should the upper bound be strict?

Value

a CheckResult object

Examples

1
2
3
4
5
6
7
8
9
df <- data.frame(a = c(1, 2, 3, NA), b = c(4, 5, 6, 7))
cb1 <- check_between(a = c(1, 4), b = c(3, 7))
cb1(df) # passes
cb2 <- check_between(a = c(1, 4), b = c(3, 7), .strict_lower = TRUE)
cb2(df) # fails
cb3 <- check_between(a = c(1, 4), b = c(3, 7), .strict_upper = TRUE)
cb3(df) # fails
cb4 <- check_between(a = c(1, 4), b = c(3, 7), .strict_lower = TRUE, .strict_upper = TRUE)
cb4(df) # fails

colin-fraser/CanonicalForms documentation built on Jan. 8, 2022, 8:42 a.m.