DescTools (version 0.99.8.1)

Closest: Find the Closest Value

Description

Find the closest value of a number in a vector x.

Usage

Closest(x, a, na.rm = FALSE)

Arguments

x
the vector to be searched in
a
the reference value
na.rm

Value

  • the value in x which is closest to a

See Also

which

Examples

Run this code
set.seed(8)
x <- sample(10, size=10, replace=TRUE)

Closest(x, 6)

Run the code above in your browser using DataLab