all_equal_recursively: Recursive comparisons for equality which also works for...

View source: R/miscellaneous_functions.R

all_equal_recursivelyR Documentation

Recursive comparisons for equality which also works for nested lists

Description

Recursive comparisons for equality which also works for nested lists

Usage

all_equal_recursively(x1, x2)

Arguments

x1

A R object

x2

A R object

Value

  • If both x1 and x2 are lists, then all_equal_recursively is called recursively on mutually shared names if names exists and on each element otherwise, and the output is a list from the return value of each recursive call.

  • Otherwise, the function all.equal is called. If the result is TRUE, then NA is returned. If the result is FALSE, then a list with three elements is returned with

    eq

    the result of the call to all.equal

    x1

    The object x1

    x2

    The object x2

See Also

all.equal

Examples

## expected result: NA
all_equal_recursively(1L, 1L)

## expected result: list(eq = "Mean relative difference: 1", x1 = 1, x2 = 2)
all_equal_recursively(1, 2)

## expected result: first comparison returns NA; second shows a difference
all_equal_recursively(list(1, 2), list(1, 3))
## expected result: comparison for elements a and b return NA; comparison
## for element c shows a difference
all_equal_recursively(list(a = 1, b = 2), list(b = 2, c = 0, a = 1))

DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.