Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

all_diff

Test if All Elements are Different


Description

all_diff tests if all elements are different. 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_diff(x)

Arguments

x

atomic vector, list vector, or list.

Details

The machine precision of all_diff 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_diff(1:10)
all_diff(c(1:10, 10))
all_diff(c(1.0000000, 1.0000001, 0.9999999)) # machine precision good for most cases

str2str

Convert R Objects from One Structure to Another

v0.1.1
GPL (>= 2)
Authors
David Disabato [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.