R/utils_classes.R

Defines functions `%nin%` cls_check

# Copied from [jdtools](https://jdtools.jdtrat.com)
cls_check <- function(object, expected_class) {

  obj_name <- deparse(substitute(object))
  obj_class <- class(object)

  if (all(obj_class %nin% expected_class)) {
    cli::cli_abort("{.arg {obj_name}} must be {.cls {expected_class}} not of {.cls {obj_class}}.",
                   class = "cls_abort")
  }

  invisible(obj_class)

}

# Copied from [jdtools](https://jdtools.jdtrat.com)
`%nin%` <- function(x, table) {
  !match(x, table, nomatch = 0L) > 0L
}

Try the tremendousr package in your browser

Any scripts or data that you put into this service are public.

tremendousr documentation built on Sept. 30, 2021, 5:09 p.m.