R/utils.R

Defines functions firstup getfun

Documented in getfun

#' @importFrom dplyr %>%

`%||%` <- function (x, y) {
  suppressWarnings({
    if (is.empty(x))
      return(y)
    else if (is.null(x) || is.na(x))
      return(y)
    else if (class(x) == "character" && all(nchar(x) == 0))
      return(y)
    else x
  })
}

is.empty <- function (x)
{
  !as.logical(length(x))
}


#' Get function from string of namespace::function() to pass to do.call
getfun <- function(x) {
  if(length(grep("::", x))>0) {
    parts <- strsplit(x, "::")[[1]]
    getExportedValue(parts[1], parts[2])
  } else {
    x
  }
}

firstup <- function(x) {
  substr(x, 1, 1) <- toupper(substr(x, 1, 1))
  x
}
datasketch/parmesan documentation built on June 12, 2022, 6:20 p.m.