Closed ddsjoberg closed 1 year ago
this could turn into a complex solution. in the meantime, this is how to get around complex env handling:
library(affirm)
affirm_init(replace = TRUE)
#> ✔ We're ready to make data affirmations...
levels <- c(4, 6, 8)
as_tibble(mtcars) |>
affirm_true(
label = "No. cylinders must be 4, 6, or 8",
condition = !!expr(cyl %in% !!levels)
)
#> • No. cylinders must be 4, 6, or 8
#> 0 issues identified.
#> # A tibble: 32 × 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> # ℹ 22 more rows
Created on 2023-06-08 with reprex v2.0.2