R/utils.R

Defines functions `%||%`

# Set a default value if an object is null
#
# @param lhs An object to set if it's null
# @param rhs The value to provide if x is null
#
# @return rhs if lhs is null, else lhs
#
# @author Hadley Wickham
# @references https://adv-r.hadley.nz/functions.html#missing-arguments
#
`%||%` <- function(lhs, rhs) {
  if (!is.null(x = lhs)) {
    return(lhs)
  } else {
    return(rhs)
  }
}

Try the bbknnR package in your browser

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

bbknnR documentation built on Sept. 23, 2022, 1:06 a.m.