Skip to contents

This function is used to check if the variable values are the same as the input values.

Usage

check_value_match(
  values,
  check_list,
  excluded.na = TRUE,
  stop_message = FALSE,
  add_stop_message = NULL,
  value_split = FALSE,
  split_pattern = "\\||:|;"
)

Arguments

values

Existed variable values

check_list

Vector of input values

excluded.na

A Boolean to skip NA from the existed variable values values, Default: TRUE

stop_message

A Boolean value to return a stop message if one of the existed values does not match with the check list, Default: FALSE

add_stop_message

Additional text message that will be added in the stop message.

value_split

A Boolean value whether to split the values with specified split pattern split_pattern

split_pattern

Split string pattern. Only applicable if value_split = TRUE

Value

TRUE

If all the existed variable values are matched with the input values

FALSE

Otherwise and with a stop message if stop_message = TRUE

Examples

if (FALSE) { # \dontrun{
check_value_match(
  values = c("-2", "2"),
  check_list = c("-2"),
  stop_message = FALSE
)
check_value_match(
  values = c("-2", "2", NA),
  check_list = c("-2", "2"),
  excluded.na = TRUE,
  stop_message = FALSE
)
} # }