Description Usage Arguments Value Examples
This function is adapted from
gargle's
abort_bad_class
function. It provides an informative error message
indicating the object and the class it must be for the function to work
properly.
1 | cls_abort(object, expected_class)
|
object |
The object whose class should be checked. |
expected_class |
A character vector of expected (or allowed) classes. |
NA; triggers an error.
1 2 3 4 5 6 7 8 9 10 11 | if (interactive()) {
is_df <- function(x) {
if (is.data.frame(x)) {
cls_abort(mtcars, expected_class = c("character", "numeric"))
}
}
is_df(mtcars)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.