is_factor: Check if the passed entity is a factor.

View source: R/factor.R

is_factorR Documentation

Check if the passed entity is a factor.

Description

Check if the passed entity is a factor.

Usage

is_factor(
  value,
  exact_levels = NULL,
  exact_length = NULL,
  allow_null = FALSE,
  allow_na_values = FALSE
)

Arguments

value

the value to check

exact_levels

vector of strings of the expected levels of the factor. The factor must contain *exactly* the specified elements.

exact_length

integer value. If passed, the factor must have the *exact* specified length.

allow_null

boolean. if TRUE, NULL is accepted as a valid value. If FALSE (default) do not accept it.

allow_na_values

boolean. If passed allows factors containing NAs. The length check is performed including the NA values. Default FALSE.

Examples

## Not run: 
# For assertion
assertthat::assert_that(qscheck::is_factor(my_parameter))
# For check
if (qscheck::is_factor(my_parameter)) {}

## End(Not run)



AstraZeneca/qscheck documentation built on Nov. 1, 2023, 4:45 a.m.