View source: R/miscellaneous_functions.R
all_equal_recursively | R Documentation |
Recursive comparisons for equality which also works for nested lists
all_equal_recursively(x1, x2)
x1 |
A R object |
x2 |
A R object |
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
the result of the call to all.equal
The object x1
The object x2
all.equal
## 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.