Function to check mismatch between actual object class and anticipated type
Usage
check_object_type(
x,
type,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)Arguments
- x
Input value
- type
Object type
- arg
See
caller_arg- call
See
caller_env
Details
This function is used to check the object type of an input value based on
base R package. In base R package, object type functions are
specified in is.ObjectType format.
For instance, base::is.logical is used for checking a logical/Boolean
value. Please see examples below how base functions are translated in this function.
Examples
if (FALSE) { # \dontrun{
# Without error message
check_object_type(x = letters[1:12], type = "character")
check_object_type(x = ADNIMERGE2::CDR, type = "data.frame")
check_object_type(x = TRUE, type = "logical")
# With error message
check_object_type(x = letters[1:12], type = "numeric")
check_object_type(x = letters[1:12], type = "factor")
} # }
