View source: R/all_different.R
all_different | R Documentation |
These functions determine whether numeric values are sufficiently different from each other based on a specified tolerance.
all_different
: Checks if all differences between entries in a numeric object exceed a given tolerance.
values_different
: Adds candidate values to a set of initial values only if they are sufficiently different from all existing values.
all_different(obj, tol)
values_different(values, candidates, tol = 0.1)
obj |
Numeric vector, matrix, or data frame to test for differences. Non-numeric inputs will be coerced to numeric if possible. |
tol |
Numeric scalar specifying the minimum allowable difference between values. |
values |
Numeric vector of initial values. |
candidates |
Numeric vector of candidate values to add if sufficiently different. |
all_different
: Logical (TRUE
if all differences exceed tol
, FALSE
otherwise).
values_different
: Numeric vector with original values
plus any candidates
that meet the difference criterion.
# Check if all values are sufficiently different
x <- runif(10) # 10 random values between 0 and 1
all_different(x, tol = 0.01)
all_different(x, tol = 0.5)
# Add sufficiently different candidate values
starting_values <- c(0.1, 0.5, 0.9)
candidates <- c(0.15, 0.4, 0.8, 1.2)
values_different(starting_values, candidates, tol = 0.2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.