check_input {BayesTools}R Documentation

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, call = "")

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

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

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

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

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.

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

Value

returns NULL, called for the input check.

Examples

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

# will throw an error on any other type
## Not run: 
  check_bool("TRUE", name = "input")

## End(Not run)


[Package BayesTools version 0.1.3 Index]