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)
}
hadley/readxl documentation built on Oct. 15, 2023, 10:28 a.m.