powered by
This function checks that x is a subset of y
x
y
assert_subset(x, y, msg = NULL, call = rlang::caller_env(), arg_name = NULL)
Returns invisible(TRUE) if x is a subset of y, otherwise throws an error
A vector to check
the acceptible values that x can take
The error message thrown if the assertion fails (string)
Only relevant when pooling assertions into multi-assertion helper functions. See cli_abort for details.
Advanced use only. Name of the argument passed (default: NULL, will automatically extract arg_name).
try({ assert_subset(1:3, 1:5) # Passes assert_subset(c("A", "B", "C"), c("A", "B")) # Throws error since "C" is not present in first vector })
Run the code above in your browser using DataLab