# 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 of class "foo" or "bar"?
if (FALSE) {
assert(
checkClass(x, "foo"),
checkClass(x, "bar")
)
}
# is x most specialized as "bar"?
testClass(x, "bar", ordered = TRUE)
Run the code above in your browser using DataLab