Learn R Programming

papaja (version 0.1.0.9054)

validate: Validate function input

Description

This functions can be used to validate the input to functions. This function is not exported.

Usage

validate(x, name = NULL, check_class = NULL, check_integer = FALSE, check_NA = TRUE, check_infinite = TRUE, check_length = NULL, check_dim = NULL, check_range = NULL)

Arguments

x
Function input.
name
Character. Name of variable to validate; if NULL variable name of object supplied to x is used.
check_class
Character. Name of class to expect.
check_integer
Logical. If TRUE an object of type integer or an whole number numeric is expected.
check_NA
Logical. If TRUE an non-NA object is expected.
check_infinite
Logical. If TRUE a finite object is expected.
check_length
Integer. Length of the object to expect.
check_dim
Numeric. Vector of object dimensions to expect.
check_range
Numeric. Vector of length 2 defining the expected range of the object.

Examples

Run this code
## Not run: 
# in_paren <- TRUE # Taken from printnum()
# validate(in_paren, check_class = "logical", check_length = 1)
# validate(in_paren, check_class = "numeric", check_length = 1)
# ## End(Not run)

Run the code above in your browser using DataLab