Learn R Programming

BayesTools (version 0.2.18)

check_input: Check input

Description

A set of convenience functions for checking objects/arguments to a function passed by a user.

Usage

check_bool(
  x,
  name,
  check_length = 1,
  allow_NULL = FALSE,
  allow_NA = TRUE,
  call = ""
)

check_char( x, name, check_length = 1, allow_values = NULL, allow_NULL = FALSE, allow_NA = TRUE, call = "" )

check_real( x, name, lower = -Inf, upper = Inf, allow_bound = TRUE, check_length = 1, allow_NULL = FALSE, allow_NA = TRUE, call = "" )

check_int( x, name, lower = -Inf, upper = Inf, allow_bound = TRUE, check_length = 1, allow_NULL = FALSE, allow_NA = TRUE, call = "" )

check_list( x, name, check_length = 0, check_names = NULL, all_objects = FALSE, allow_other = FALSE, allow_NULL = FALSE, call = "" )

Value

returns NULL, called for the input check.

Arguments

x

object to be checked

name

name of the object that will be print in the error message.

check_length

length of the object to be checked. Defaults to 1. Set to 0 in order to not check object length.

allow_NULL

whether the object can be NULL. If so, no checks are executed.

allow_NA

whether the object can contain NA or NaN values.

call

string to be placed as a prefix to the error call.

allow_values

names of values allowed in a character vector. Defaults to NULL (do not check).

lower

lower bound of allowed values. Defaults to -Inf (do not check).

upper

upper bound of allowed values. Defaults to Inf (do not check).

allow_bound

whether the values at the boundary are allowed. Defaults to TRUE.

check_names

names of entries allowed in a list. Defaults to NULL (do not check).

all_objects

whether all entries in check_names must be present. Defaults to FALSE.

allow_other

whether additional entries then the specified in check_names might be present

Examples

Run this code
# check whether the object is logical
check_bool(TRUE, name = "input")

# will throw an error on any other type
if (FALSE) {
  check_bool("TRUE", name = "input")
}

Run the code above in your browser using DataLab