stopifnot(!all_identical(1:3))
stopifnot(all_identical(list("a", "a", "a")))
# Using with `all.equal()` has its quirks
# because of numerical tolerance:
x <- seq(
.Machine$double.eps,
.Machine$double.eps + 1.1 * sqrt(.Machine$double.eps),
length = 3
)
# Results with `all.equal()` are affected by ordering
all_identical(x, all.equal) # FALSE
all_identical(x[c(2,3,1)], all.equal) # TRUE
# ... because `all.equal()` is intransitive
all_identical(x[-3], all.equal) # is TRUE and
all_identical(x[-1], all.equal) # is TRUE, but
all_identical(x[-2], all.equal) # is FALSE
Run the code above in your browser using DataLab