almost_unique: Almost unique elements

Description Usage Arguments Value See Also Examples

View source: R/almost_unique.R

Description

The function almost_unique extracts elements of a vector x that are unique up to a tolerance factor.

Usage

1
2
3
4
5
6
7
almost_unique(x, ...)

almost.unique(x, ...)

## Default S3 method:
almost_unique(x, tolerance = sqrt(.Machine$double.eps),
  ...)

Arguments

x

numeric. The vector of numeric values at stake.

...

Additional arguments to be passed to the function duplicated, which is used internally by almost_unique.

tolerance

numeric. Relative differences smaller than tolerance are considered as equal. The default value is close to 1.5e-8.

Value

A vector of the same type as x.

See Also

unique, duplicated.

Examples

1
2
3
4
5
6
almost_unique(c(1, 1.01), tol = 0.1)
almost_unique(c(1, 1.01), tol = 0.01)

almost_unique(c(1, 2, 3), tol = 10)
almost_unique(c(1, 2, 3), tol = 5)
almost_unique(c(1, 2, 3), tol = 1)

paulponcet/bazar documentation built on July 15, 2019, 5:28 a.m.