all_same {str2str} | R Documentation |
Test if All Elements are the Same
Description
all_same
tests if all elements are the same. The elements could be either
from an atomic vector, list vector, or list. If x
does not have any unique
values (e.g., NULL), then FALSE is returned.
Usage
all_same(x)
Arguments
x |
atomic vector, list vector, or list. |
Details
The machine precision of all_same
for numeric vectors is the same as
unique
. This can causes a problem for some floating-point numbers.
Value
logical vector of length 1 specifying whether all the elements in x
are the same (TRUE) or not (FALSE).
Examples
all_same(rep.int("a", times = 10))
all_same(rep.int(1, times = 10))
all_same(c(1.0000000, 1.0000001, 0.9999999)) # machine precision good for most cases
all_same(1) # works for vectors of length 1
[Package str2str version 1.0.0 Index]