get_closest: get_closest

Description Usage Arguments Value Examples

View source: R/get_closest.R

Description

Returns the indices of the top k rows in a dataframe that are closest to a given obversation (point) based on a specificed distance metric.

Usage

1
get_closest(point, data, top_k, metric = "euclidean")

Arguments

point

Vector, values defining a single observation to compute distances for

data

Dataframe, values of all observations to calculate distances from point

top_k

Integer, number of closest observations to return indices for

metric

Char, type of distance metric to use in distance calculations

Value

Vector, indices of the closest k observations from data

Examples

1
2
df <- data.frame(x=c(1, 1), y=c(1,2))
get_closest(c(1,1), df, 2)

UBC-MDS/distrrr documentation built on May 6, 2019, 12:07 p.m.