R/ifelseObj.R

Defines functions ifelseObj

Documented in ifelseObj

#' Conditional returning of an object
#'
#' The ifelseObj function just evaluates a condition, returning
#'   one object if it's true, and another if it's false.
#'
#' @param condition Condition to evaluate.
#' @param ifTrue Object to return if the condition is true.
#' @param ifFalse Object to return if the condition is false.
#'
#' @return One of the two objects
#' @export
#'
#' @examples dat <- ifelseObj(sample(c(TRUE, FALSE), 1), mtcars, Orange);
#'

ifelseObj <- function(condition, ifTrue, ifFalse) {
  if (condition) {
    return(ifTrue);
  }
  else {
    return(ifFalse);
  }
}

Try the ufs package in your browser

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

ufs documentation built on July 9, 2023, 6:07 p.m.