check_functions {sits}R Documentation

Check functions

Description

Functions used to check parameters in a systematic way.

Usage

.check_set_caller(caller)

.check_identify_caller()

.check_that(x, ..., local_msg = NULL, msg = NULL)

.check_null(x, ..., msg = NULL)

.check_na(x, ..., msg = NULL)

.check_names(x, ..., is_named = TRUE, msg = NULL)

.check_length(x, ..., len_min = NULL, len_max = NULL, msg = NULL)

.check_apply(x, fn_check, ...)

.check_lgl_type(x, ..., msg = NULL)

.check_num_type(x, ..., is_integer = FALSE, msg = NULL)

.check_chr_type(x, ..., msg = NULL)

.check_lst_type(x, ..., msg = NULL)

.check_lgl(
  x,
  ...,
  allow_na = FALSE,
  len_min = NULL,
  len_max = NULL,
  allow_null = FALSE,
  is_named = FALSE,
  msg = NULL
)

.check_num(
  x,
  ...,
  allow_na = FALSE,
  min = -Inf,
  max = Inf,
  allow_zero = TRUE,
  len_min = NULL,
  len_max = NULL,
  allow_null = FALSE,
  is_integer = FALSE,
  is_named = FALSE,
  msg = NULL
)

.check_chr(
  x,
  ...,
  allow_na = FALSE,
  allow_empty = TRUE,
  len_min = NULL,
  len_max = NULL,
  allow_null = FALSE,
  is_named = FALSE,
  regex = NULL,
  msg = NULL
)

.check_lst(
  x,
  ...,
  min_len = NULL,
  max_len = NULL,
  allow_null = FALSE,
  is_named = TRUE,
  fn_check = NULL,
  msg = NULL
)

.check_chr_within(
  x,
  within,
  ...,
  case_sensitive = TRUE,
  discriminator = "all_of",
  can_repeat = TRUE,
  msg = NULL
)

.check_chr_contains(
  x,
  contains,
  ...,
  case_sensitive = TRUE,
  discriminator = "all_of",
  can_repeat = TRUE,
  msg = NULL
)

.check_file(x, ..., extensions = NULL, msg = NULL)

.check_env_var(x, ..., msg = NULL)

.check_warn(expr)

.check_error(expr, ..., msg = NULL)

Arguments

caller

A character value with the caller name.

x

Any object that will be evaluated.

...

Additional parameters for fn_check function.

local_msg

A character with the generic error message that will be shown inside parenthesis.

msg

A character with the error message that will be shown as the main message to the user.

is_named

A logical indicating if the check permits unnamed list.

len_min

A numeric indicating the minimum length of vector or list users provides for functions. Default is 0.

len_max

A numeric indicating the maximum length of vector or list users provides for functions. Default is 2^31.

fn_check

A function used to test each element of an object.

is_integer

A logical indicating if the value should be integer.

allow_na

A logical indicating if the check permits empty NA values. Default is FALSE.

allow_null

A logical indicating if the check permits empty NULL values. Default is FALSE.

min

A atomic vector of numeric indicating the minimum value that the user can provide in function parameter. Only works for numeric check. By default is -Inf.

max

A atomic vector of numeric indicating the maximum value that the user can provide in function parameter. Only works for numeric check. By default is Inf.

allow_zero

A logical indicating if the check permits zero values. Default is TRUE.

allow_empty

A logical indicating if the check permits empty list. Default is TRUE.

regex

A character value with regular expression to be evaluated against data.

min_len

A numeric indicating the minimum length of vector or list users provides for functions. Default is 0.

max_len

A numeric indicating the maximum length of vector or list users provides for functions. Default is 2^31.

within

A character vector indicating a set of elements from which x is a kind of subset. The actual behavior is pointed by discriminator parameter.

case_sensitive

A logical indicating if the check is compared with case sensitive. Default is TRUE.

discriminator

A character value indicating how subset verification will be done (see details).

can_repeat

A logical value indicating if vector x can have repeated elements or not.

contains

A character vector indicating a set of elements to which x is a kind of superset. The actual behavior is pointed by discriminator parameter.

extensions

A character vector with all allowed file extensions.

expr

A R expression to be evaluated.

Details

Error message functions:

General check functions:

Check type functions:

Combined check functions. These function combine some checks mentioned above in one place. In general, these functions can check for NA (if allow_na=FALSE), for value length (if either len_min and len_max are defined - for list the parameters are min_len and max_len, respectively), for NULL value (if allow_null=FALSE), and for names (if is_named is TRUE or FALSE). Depending on specific type, the functions also check for:

Subset check functions. Two functions are provided to check for subset elements in character vectors. These functions are the symmetrical equivalent to each other, but the error messages are different. For the .check_chr_within(), the error message focus on the within values. For the .check_chr_contains(), the error message focus on the contains values. The verification is done accordingly to the discriminator parameter, that can be: one_of, any_of, all_of, none_of, or exactly.

Special checking function:

Special checking function:

Contextual check and error conversion functions:

Value

Unless otherwise specified, all checking functions return the same argument as x if a TRUE evaluation occurs.

.check_set_caller() returns NULL.

.check_identify_caller() returns a character value.


[Package sits version 0.16.2 Index]