R/utils.R

Defines functions compact is_installed print_metadata combine_paths

compact <- function(x) {
  is_null <- vapply(x, is.null, logical(1))
  x[!is_null]
}

is_installed <- function(pkg) {
  system.file(package = pkg) != ""
}

print_metadata <- function(x) {
  if (is.null(x)) return()

  cat("Metadata:\n")
  str(x, no.list = TRUE)
}

combine_paths <- function(x, y) {
  if (substr(y, 1, 1) == "/") return(y)

  normalizePath(file.path(x, y))
}

"%||%" <- function(a, b) if (is.null(a)) b else a
hadley/rsmith documentation built on May 17, 2019, 12:16 p.m.