check_no_nas: Check makers

Description Usage Arguments Details Functions Examples

View source: R/checks.R

Description

Create checks to add to Canonical Forms. Each of these functions returns a function which takes a dataframe and returns a CheckResult object.

Usage

1
2
3
4
5

Arguments

cols

character vector of columns to include in the check

...

named arguments of the form (col = constraint)

.strict

should values equal to the constraint be disallowed?

Details

for check_greater_than and check_less_than, different values can be specified for each column. See examples.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
df <- data.frame(a = c(1, 2, NA), b = c(4, 5, 6))
check_na <- check_no_nas("a")
check_na(df) # fails
check_na2 <- check_no_nas("b")
check_na2(df) # passes

check_gt <- check_greater_than(a = 0, b = 3)
check_gt(df) # passes
check_gt2 <- check_greater_than(a = 1, b = 4, .strict = FALSE)
check_gt2(df) # passes (because .strict=FALSE)
check_gt3 <- check_greater_than(a = 1, b = 1, .strict = TRUE)
check_gt3(df) # fails

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