R/utils.R

`%||%` <- function(l, r) if (is.null(l)) r else l

#' @importFrom utils packageName

myfile <- function(...) {
  system.file(..., package = packageName())
}

drop_empty_strings <- function(x) {
  x [ x != "" ]
}

as_string <- function(x) {
  x <- as.character(x)
  if (length(x) != 1 || is.na(x)) stop("Expected a string")
  x
}

pretty_date <- function(x) {
  format(as.Date(x))
}
MangoTheCat/myghrepos documentation built on May 8, 2019, 3:37 p.m.