Skip to contents

check_identical() validates whether two objects are identical and raises an error if they are not. check_is_identical() returns a logical value indicating whether the two objects are identical.

Usage

check_identical(x, y, xpar_name = "xpar_name", ypar_name = "ypar_name")

check_is_identical(x, y)

Arguments

x

The first object to compare.

y

The second object to compare.

xpar_name

Optional. A custom name for the first parameter used in error messages.

ypar_name

Optional. A custom name for the second parameter used in error messages.

Value

  • check_identical(): A list containing x and y if they are identical, or an error if not.

  • check_is_identical(): Logical value, TRUE if the objects are identical, and FALSE otherwise.

Examples

# Examples for check_identical()
check_identical(1, 1)
#> $x
#> [1] 1
#> 
#> $y
#> [1] 1
#> 
try(check_identical(1, 2))
#> Error in check_identical(1, 2) : 
#>   Expected 'xpar_name' and 'ypar_name' to be identical.

# Examples for check_is_identical()
check_is_identical(1, 1)
#> [1] TRUE
check_is_identical(1, 2)
#> [1] FALSE