R/ifelse0.R

Defines functions ifelse0

Documented in ifelse0

#' ifelse function but then based on whether value is NULL or not
#'
#' @param value metadata list object
#' @param alternative alternative value
#' @param allow_null can the alternative be NULL?
#'
#' @export
#' @return `value` if non-NULL; `alternative` otherwise
#' @md
ifelse0 <- function(value = NULL, alternative = NULL, allow_null = FALSE) {
  if(is.null(alternative) && !allow_null) {
    stop("No alternative specified")
  }
  if(!is.null(value)) {
    return(value)
  } else {
    return(alternative)
  }
}

Try the PKPDsim package in your browser

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

PKPDsim documentation built on March 7, 2023, 5:40 p.m.