Learn R Programming

checkmate (version 1.0)

checkChoice: Check if an object is an element of a given set

Description

Check if an object is an element of a given set

Usage

checkChoice(x, choices)

assertChoice(x, choices, .var.name)

testChoice(x, choices)

Arguments

x
[ANY] Object to check.
.var.name
[character(1)] Name for x. Defaults to a heuristic to determine the name using deparse and substitute.
choices
[atomic] Set of possible values.

Value

  • Depending on the function prefix: If the check is successful, all functions return TRUE. If the check is not successful, assertChoice throws an error message, testChoice returns FALSE and checkChoice returns a string with the error message.

See Also

Other set: assertSubset, checkSubset, testSubset

Examples

Run this code
testChoice("x", letters)

Run the code above in your browser using DataLab