closest_in_vector: Get the Element(s) of a Vector Closest to a Reference Value

Description Usage Arguments Value

View source: R/closest_in_vector.R

Description

Return the k elements of a vector closest (in terms of Euclidean distance) to a reference value, as well as those elements' indices in the vector.

Usage

1
closest_in_vector(x, vec, k = 1)

Arguments

x

Reference value

vec

Vector

k

How many closest neighbours to return

Value

A data frame with the following columns, sorted by increasing distance:

index

Index of element (i.e. value is the same as vec[index])

value

Element

dist

Euclidean distance of element to reference value


hkauhanen/hipster documentation built on July 4, 2020, 11:25 p.m.