get_all_distances: Return distance/similarity metric for each row in a dataframe

Description Usage Arguments Value Examples

View source: R/get_all_distances.R

Description

Compares an input reference vector (point) to all rows of an input data frame, calculating the specified distance/similarity metric for each row.

Usage

1
get_all_distances(point, data, metric = "euclidean")

Arguments

point

vector of length k to compare to the data frame

data

data frame of size n by k to compare ref_vec to

metric

string, default value "euclidean" for euclidean distance, "cosine" will return cosine similiarity distance, and "manhattan" will return manhattan distance

Value

numeric vector of length n

Examples

1
2
3
df <- data.frame("A" = c(1,2,3), "B" = c(8,2,4))
ref_vec <- c(-2,4)
get_all_distances(ref_vec, df, metric = "euclidean")

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