R/assertions.R

Defines functions assert_same_length

# -----------------------------------------------------------------------------
# Dimensions


# -----------------------------------------------------------------------------
# x and y are same length
#' @noRd
assert_same_length <- function(x, y,
                               message =  "%s and %s must be the same length",
                               name_x = deparse(substitute(x)),
                               name_y = deparse(substitute(y))) {
  if (length(x) != length(y)) {
    stop(sprintf(message, name_x, name_y), call. = FALSE)
  }
  return(TRUE)
}


# -----------------------------------------------------------------------------
mrc-ide/ZikaModel documentation built on Sept. 14, 2022, 8:51 a.m.