Check unique
check_unique.RdCheck if arg is all unique.
Arguments
- arg
(object)
The argument to check.- 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_unique() examples
#----------------------------------------------------------------------------
library(bkcheck)
f <- function(x) {
x |>
check_unique()
}
f("a")
try(f(c(TRUE, TRUE)))
#> Error : Argument `x` must have all unique values.
#>
#> Duplicated values: TRUE
#>
#> Call: f(x = c(TRUE, TRUE))
try(f(c(1L, 1L)))
#> Error : Argument `x` must have all unique values.
#>
#> Duplicated values: 1
#>
#> Call: f(x = c(1L, 1L))
try(f(c(1, 1)))
#> Error : Argument `x` must have all unique values.
#>
#> Duplicated values: 1
#>
#> Call: f(x = c(1, 1))
try(f(c("a", "b", "a")))
#> Error : Argument `x` must have all unique values.
#>
#> Duplicated values: 'a'
#>
#> Call: f(x = c("a", "b", "a"))
try(f(factor(c("a", "a"))))
#> Error : Argument `x` must have all unique values.
#>
#> Duplicated values: 'a'
#>
#> Call: f(x = factor(c("a", "a")))