% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/arg_between.R
\name{arg_between}
\alias{arg_between}
\alias{arg_gt}
\alias{arg_gte}
\alias{arg_lt}
\alias{arg_lte}
\title{Check Values in Range}
\usage{
arg_between(
  x,
  range = c(0, 1),
  inclusive = TRUE,
  .arg = rlang::caller_arg(x),
  .msg = NULL,
  .call
)

arg_gt(x, bound = 0, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_gte(x, bound = 0, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_lt(x, bound = 0, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_lte(x, bound = 0, .arg = rlang::caller_arg(x), .msg = NULL, .call)
}
\arguments{
\item{x}{the argument to be checked}

\item{range}{a vector of two values identifying the required range.}

\item{inclusive}{a logical vector identifying whether the range boundaries are inclusive or not. If only one value is supplied, it is applied to both range boundaries. Default is \code{TRUE}, which will not throw an error if \code{x} is equal to the boundaries.}

\item{.arg}{the name of the argument supplied to \code{x} to appear in error messages. The default is to extract the argument's name using \code{\link[rlang:caller_arg]{rlang::caller_arg()}}. Ignored if \code{.msg} is supplied.}

\item{.msg}{an optional alternative message to display if an error is thrown instead of the default message.}

\item{.call}{the execution environment of a currently running function, e.g. \code{.call = rlang::current_env()}. The corresponding function call is retrieved and mentioned in error messages as the source of the error. Passed to \code{\link[=err]{err()}}. Set to \code{NULL} to omit call information. The default is to search along the call stack for the first user-facing function in another package, if any.}

\item{bound}{the bound to check against. Default is 0.}
}
\value{
Returns \code{NULL} invisibly if an error is not thrown.
}
\description{
Checks whether values are within a range (\code{arg_between()}), greater than some value (\code{arg_gt()}), greater than or equal to some value (\code{arg_gte()}), less than some value (\code{arg_lt()}), or less than or equal to some value (\code{arg_lte()}).
}
\details{
\code{x} is not checked for type, as it is possible for values other than numeric values to be passed and compared; however, an error will be thrown if \code{typeof(x)} is not equal to \code{typeof(range)} or \code{typeof(bound)}. \code{NA} values of \code{x} will be removed. The arguments to \code{range}, \code{inclusive}, and \code{bound} are checked for appropriateness.
}
\examples{
z <- 2

try(arg_between(z, c(1, 3))) # No error
try(arg_between(z, c(1, 2))) # No error
try(arg_between(z, c(1, 2),
                inclusive = FALSE)) # Error
try(arg_between(z, c(1, 2),
                inclusive = c(TRUE, FALSE))) # Error

try(arg_gt(z, 0))  # No error
try(arg_gt(z, 2))  # Error
try(arg_gte(z, 2)) # No error

try(arg_lt(z, 0))  # Error
try(arg_lt(z, 2))  # Error
try(arg_lte(z, 2)) # No error

try(arg_lte(z, "3")) # Error: wrong type
}
