R/utils.R

Defines functions with_safe_path warn0 if_any stop0 `%fl%`

`%fl%` <- function(x, y) {
  if (!all(file.exists(x))) {
    y
  } else {
    x
  }
}

stop0 <- function(...) {
  stop(..., call. = FALSE)
}

if_any <- function(condition, x, y) {
  if (condition) {
    x
  } else {
    y
  }
}

warn0 <- function(...) {
  warning(..., call. = FALSE)
}

with_safe_path <- function(path, code) {
  if (!is.null(path) && !is.na(path) && path != "") {
    withr::with_path(path, code)
  } else {
    code
  }
}

Try the proffer package in your browser

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

proffer documentation built on Feb. 16, 2023, 7:07 p.m.