findKNN: calculates an approximate KNN for sourceDf entries in...

View source: R/tidyKNN.R

findKNNR Documentation

calculates an approximate KNN for sourceDf entries in targetDf entries

Description

relise on RANN library for actual calculation. Simply reformats the results into a mapping table format

Usage

findKNN(
  sourceDf,
  targetDf,
  sourceIdVar,
  targetIdVar,
  k = 4,
  matchVars = vars(long, lat),
  distanceVar = "distance",
  rankVar = "rank",
  ...
)

Arguments

sourceDf

a dataframe with a unique Id column

targetDf

a dataframe with a unique Id column

sourceIdVar

the unique Id column of the sourceDf

targetIdVar

the unique Id column of the targetDf

k

the k of knn

matchVars

the columns to calculate the distance on - must be numerics and present in both sourceDf and targetDf, escaped by vars(...)

distanceVar

what will the distance measure be named?

...

other parameters passed onto RANN::nn2()

Value

a dataframe containing sourceIdVar, targetIdVar, distanceVar and k columns


terminological/tidy-info-stats documentation built on Nov. 19, 2022, 11:23 p.m.