R/utils.R

Defines functions is_string is_integerish check_file

check_file <- function(path) {
  if (!is_string(path)) {
    stop("`path` must be a string", call. = FALSE)
  }

  if (!file.exists(path)) {
    stop("`path` does not exist: ", sQuote(path), call. = FALSE)
  }
  path
}

is_integerish <- function(x) {
  floor(x) == x
}

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

Try the readxl package in your browser

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

readxl documentation built on July 9, 2023, 5:57 p.m.