R/assertions.R

Defines functions is_count is_number

is_number <- function(x, null_ok = FALSE) {
  if (null_ok && is.null(x)) {
    return(TRUE)
  }
  is.numeric(x) && length(x) == 1L && !is.na(x)
}

is_count <- function(x, null_ok = FALSE) {
  if (null_ok && is.null(x)) {
    return(TRUE)
  }
  is.numeric(x) && length(x) == 1L && is.finite(x) && x == trunc(x) && x > 0
}

Try the gmeans package in your browser

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

gmeans documentation built on Sept. 12, 2026, 1:06 a.m.