R/utils.R

Defines functions safe_examples is_class is_type is_count is_string_or_null is_string

int <- as.integer

is_string <- function(x) {
  is.character(x) && length(x) == 1 && !is.na(x)
}

is_string_or_null <- function(x) {
  is.null(x) || is_string(x)
}

is_count <- function(x) {
  is.integer(x) && length(x) == 1 && !is.na(x)
}

is_type <- function(x) {
  is_count(x)
}

is_class <- function(x) {
  is_count(x)
}

safe_examples <- function() {
  !is_cran_check() && is_online()
}

is_cran_check <- function () {
  if (identical(Sys.getenv("NOT_CRAN"), "true")) {
    FALSE
  } else {
    Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != ""
  }
}

Try the pingr package in your browser

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

pingr documentation built on May 29, 2024, 12:05 p.m.