Check any arg in x
check_any_arg_in_x.RdCheck if any(arg %in% x).
Arguments
- arg
(object)
The argument to check.- x
(Atomic vector)
At least one element ofargmust have a matching value inx.- signal
(string:
c("error", "warning", "message"))
Must be one of"error","warning", or"message"."error"(default) callsbase::stop()to signal an error message."warning"callsbase::warning()to signal a warning message."message"callsbase::message()to signal a message.- msg
(string or
NULL:NULL)
A string that replaces the default message. Set asNULLto use the default message.- call.
(Scalar logical:
c(FALSE, TRUE))
Passed tostop()orwarning(). The defaultmsgincludes it's own formatted call, hencecall.should beFALSE(default). If you insert your ownmsg, then you may wantcall. = TRUE.
Examples
#----------------------------------------------------------------------------
# check_any_arg_in_x() examples
#----------------------------------------------------------------------------
library(bkcheck)
f <- function(x) {
vec <- 1:2
x |>
check_any_arg_in_x(vec)
}
f(1:10)
try(f(3:10))
#> Error : Argument `x` must share at least one value with the comparison set.
#>
#> Values in `x`: 3, 4, 5, 6, 7, 8, 9, ...
#> Comparison set: 1, 2
#>
#> Call: f(x = 3:10)