R/custom_assertions.R

Defines functions assert_not_data_table check_not_data_table

# Built following instructions from
# https://mllg.github.io/checkmate/articles/checkmate.html#extending-checkmate
check_not_data_table <- function(x) {
  if (inherits(x, "data.table")) {
    return("must NOT be a data.table")
  }
  return(TRUE)
}

assert_not_data_table <- function(
    x,
    .var.name = checkmate::vname(x),
    add = NULL
) {
  if (missing(x)) {
    stop(sprintf(
      "argument \"%s\" is missing, with no default",
      .var.name
    ))
  }
  res <- check_not_data_table(x)
  checkmate::makeAssertion(x, res, .var.name, add)
}

Try the linelist package in your browser

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

linelist documentation built on June 22, 2024, 10:54 a.m.