[R] pair matching

Liaw, Andy andy_liaw at merck.com
Tue May 12 20:03:09 CEST 2009


If the matching need not be one-to-one, then you can just compute the
Euclidean distances between the two vectors, then in each row (or
column, which ever corresponds to the shorter vector) and find the
smallest.  This should be fairly easy to do.

Andy 

From: Thomas S. Dye
> 
> Given two numeric vectors of possibly unequal length, I'd 
> like to pair  
> each element of the shorter vector with an element of the longer  
> vector such that the sum of squared differences between the pairs is  
> minimized.  Can someone point me to an R function or an 
> algorithm for  
> accomplishing this?
> 
> All the best,
> Tom
> 
> Thomas S. Dye, Ph.D.
> T. S. Dye & Colleagues, Archaeologists, Inc.
> Phone: (808) 529-0866 Fax: (808) 529-0884
> http://www.tsdye.com
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}



More information about the R-help mailing list