| checkClass {checkmate} | R Documentation |
Check argument inheritance
checkClass(x, classes, ordered = FALSE) assertClass(x, classes, ordered = FALSE, .var.name) testClass(x, classes, ordered = FALSE)
x |
[any] |
classes |
[ |
ordered |
[ |
.var.name |
[character(1)] |
Depending on the function prefix:
If the check is successful, all functions return TRUE.
If the check is not successful, assertClass throws an error message,
testClass returns FALSE and checkClass returns
a string with the error message.
# Create an object with classes "foo" and "bar"
x = 1
class(x) = c("foo", "bar")
# is x of class "foo"?
testClass(x, "foo")
# is x of class "foo" and "bar"?
testClass(x, c("foo", "bar"))
# is x most specialized as "bar"?
testClass(x, "bar", ordered = TRUE)