check_factor_levels: Check factor levels

Description Usage Arguments Value Examples

View source: R/checks.R

Description

Check factor levels

Usage

1

Arguments

...

named list where each name is a column name and each value is the expected factor vector

Value

a check result which passes if each column's levels are equal to the given canonical levels

Examples

1
2
3
4
5
6
7
8
df <- data.frame(
  a = as.factor(c("a", "b", "c", "c")),
  b = as.factor(c("a", "b", "c", "d"))
)
passer <- check_factor_levels(a = c("a", "b", "c"), b = c("a", "b", "c", "d"))
failer <- check_factor_levels(a = c("a", "b", "c"), b = c("d", "e", "f", "g"))
passer(df)
failer(df)

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