check_class: Check Argument's Class

View source: R/cli.R

check_classR Documentation

Check Argument's Class

Description

Check if argument is of proper class.

Usage

check_class(x, arg_class, alt_null = FALSE, add_msg = NULL)

Arguments

x

Function argument that is being asserted.

arg_class

Class name. Usually "character", "numeric", "data.frame", etc.

alt_null

Logical. Should argument accept NULL value.

add_msg

Is an additional message that can be printed over the standard function error message. You can:

  • pass the names of the arguments that failed the test by using {x_names} in the message body (e.g. "What are the {x_names}");

  • pass the tested class by using {arg_class} in the message body (e.g. "I want them to be {arg_class})"

  • pass the classes of the arguments that failed the test by using {wrong_class} in the message body (e.g. "{wrong_class} is wrong")

Value

If argument class is same as arg_class it returns invisible NULL. Otherwise the function throws an error.


cloudfs documentation built on May 29, 2024, 11:08 a.m.