if (FALSE) {
x <- 1
class(x) <- c("a", "b")
y <- 2
class(y) <- c("c", "d")
check_binary_classes(x, y, c("d", "e"))
check_binary_classes(x, y, c("d", "e"), operator = "+")
check_binary_classes(x, y, c("d", "e"), c("a", "f"))
check_binary_classes(x, y, c("d", "e"), c("a", "f"), commutative = FALSE)
# customize error message with `glue::glue()` syntax
check_binary_classes(
x, y, c("d", "e"),
specific = "Left: {feature_x[1]}, {feature_x[2]}.",
supplement = "Right: {feature_y[1]}, {feature_y[2]}."
)
}
Run the code above in your browser using DataLab