| all_equal {filesstrings} | R Documentation |
An alternative version of base::all.equal().
Description
This function will return TRUE whenever base::all.equal()
would return TRUE, however it will also return TRUE in some other cases:
If
ais given andbis not,TRUEwill be returned if all of the elements ofaare the same.If
ais a scalar andbis a vector or array,TRUEwill be returned if every element inbis equal toa.If
ais a vector or array andbis a scalar,TRUEwill be returned if every element inais equal tob.
This function ignores names and attributes (except for dim).
When this function does not return TRUE, it returns FALSE (unless it
errors). This is unlike base::all.equal().
Usage
all_equal(a, b = NULL)
Arguments
a |
A vector, array or list. |
b |
Either |
Value
TRUE if "equality of all" is satisfied (as detailed in
'Description' above) and FALSE otherwise.
Note
This behaviour is totally different from
base::all.equal().There's also
dplyr::all_equal(), which is different again. To avoid confusion, always use the fullfilesstrings::all_equal()and neverlibrary(filesstrings)followed by justall_equal().
Examples
all_equal(1, rep(1, 3))
all_equal(2, 1:3)
all_equal(1:4, 1:4)
all_equal(1:4, c(1, 2, 3, 3))
all_equal(rep(1, 10))
all_equal(c(1, 88))
all_equal(1:2)
all_equal(list(1:2))
all_equal(1:4, matrix(1:4, nrow = 2)) # note that this gives TRUE