[R] pairs matchning

From: Federico Calboli <f.calboli_at_imperial.ac.uk>
Date: Thu 26 Oct 2006 - 16:47:49 GMT


Hi All,

I have two numerical matrices of 2 columns and many rows.

The two coulumns of matrix (1) form a number of 'pairs' of numbers, e.g:

      [,1] [,2]
[1,] 1 0
[2,] 3 4
[3,] 3 4
[4,] 5 8
[5,] 1 0
[6,] 1 0
[7,] 6 7

Matrix (2) contains the *unique* pairs:

      [,1] [,2]
[1,] 1 0
[2,] 3 4
[3,] 5 8
[4,] 6 7

I would like to create a vector matching the pairs in matrix (1) to the unique pairs in matrix (2), e.g:

[1] 1 2 2 3 1 1 4

(done by hand)

match() does not seem to be able to handle pairs, and I don't seem to be able to find an elegant solution...

Cheers,

Federico

-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Fri Oct 27 05:15:24 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 27 Oct 2006 - 01:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.