R/add_range.R

Defines functions add_range

Documented in add_range

#' Discrete range
#'
#' Checks if a variable is within a discrete range.
#' @param variable variable.
#' @param range Allowed range.
#' @param message Message to be printed in case of failure.
#' @return No return value, only performs a check.
#' @export
add_range <- function(variable, range, message){
  if(is.null(variable) || !length(variable) || !all(variable %in% range)){
    stop(paste("'",variable,"' argument must be one of:", message))
  }
}

Try the DIETCOST package in your browser

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

DIETCOST documentation built on June 8, 2025, 1:51 p.m.