matchByDistance: Match elements of one set with closest elements of another...

Description Usage Arguments Details Value Author(s)

View source: R/merge_utils.R

Description

Match elements of one set with closest elements of another set, according to their mutual distances.

Usage

1
matchByDistance(distMat, onto = TRUE)

Arguments

distMat

A distance matrix - the (i,j) element indicates the distance between the i'th element of the first set of things and the j'th element of the second set of things.

onto

If TRUE (default) then ensure all columns are matched by at least one row if possible.

Details

This function tries to match elements of one set with the closest elements of another set according to the distances between these elements as supplied by 'distMat'. By default it tries to ensure that every element of the second set (corresponding to the columns of 'distMat') is matched with at least one element of the first set (corresponding to the rows of 'distMat'). So if 'distMat' is a square matrix it calculates an exact pairwise matching between row elements & column elements. If No. rows of 'distMat' < No. of columns of 'distMat' then some columns will not be matched. If No. rows of 'distMat' > No. of columns of 'distMat' then some columns will be matched more than once. Alternatively, if the 'onto' parameter is set to FALSE then each row will be matched with the closest column regardless of whether or not that column is matched by another row.

Value

A vector whose i'th entry indicates the element in the 2nd set matching the i'th element in the 1st set.

Author(s)

Ben Veal


vapniks/mergeutils documentation built on May 3, 2019, 4:33 p.m.