This special class can be passed as a `ptype`

in order to specify that the
result should be a factor that contains at least the specified levels.

partial_factor(levels = character())

levels | Character vector of labels. |
---|

# Assert that `x` is a factor vec_assert(factor("x"), partial_factor()) # Testing with `factor()` is too strict, # because it tries to match the levels exactly # rather than learning them from the data. try(vec_assert(factor("x"), factor()))#> Error : `factor("x")` must be a vector with type <factor<>>. #> Instead, it has type <factor<bf275>>.#> Error : `factor("x")` must be a vector with type: #> #> <partial_factor< #> fd1ad {partial} #> >> #> #> Instead, it has type <factor<bf275>>.#> partial_factor< #> 5ec15 {partial} #> >#> factor(0) #> Levels: v w x y