check_value: Check the input value to a parent function argument

View source: R/utils.R

check_valueR Documentation

Check the input value to a parent function argument

Description

Within a function, this function checks the value of an input to an argument of that function. If the input value is supported, the function simply returns this value. If the input is not supported, the function either throws an error or returns a warning and the default value.

Usage

check_value(
  arg = deparse(substitute(input)),
  input,
  supp,
  warn = TRUE,
  default = supp[1]
)

Arguments

arg

A character string which defines the argument of the parent function.

input

The input to an argument of a parent function.

supp

A vector of supported input values for the argument in the parent function.

warn

A logical input which defines whether or not to return a warning and the default value (see default) or an error.

default

The default input value for the parent function.

Value

The function returns input, an error or a warning and default depending on whether or not input is within supp (i.e., whether or not the input to the argument of a parent function is supported).

Author(s)

Edward Lavender


edwardlavender/fvcom.tbx documentation built on Nov. 26, 2022, 10:28 p.m.