[R] Comparing rows of matrices with different dimensions

From: Antje Döring <Antje.Doering_at_komdat.com>
Date: Tue 22 Nov 2005 - 02:57:05 EST

 

Hi there,  

I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly?  

Here it is:  

I have two matrices:  

a

     [,1] [,2] [,3]

[1,] 1 4 9

[2,] 2 6 10

[3,] 3 6 11

[4,] 4 8 12
   

b

     [,1] [,2]

[1,] 1 4

[2,] 2 5

[3,] 3 6
 

Now I want to find out which rows of b can also be found in a (without its last column). So the solution must be something like either "TRUE FALSE TRUE" or the rows where their is a match (rows 1 and 3)  

Till now I have tried things like b %in% a[,1:2] or so but that doesn't work because I want to compare the WHOLE row of b with the whole row of a without column 3.  

Thank you very much for any help.  

Regards, Antje

        [[alternative HTML version deleted]]



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 Received on Tue Nov 22 03:05:07 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:14 EST